diff --git a/src/i3msg.rs b/src/i3msg.rs index 9b3ad32..ec8c617 100644 --- a/src/i3msg.rs +++ b/src/i3msg.rs @@ -29,9 +29,7 @@ impl<'payload> I3msg<'payload> { IoSlice::new(self.payload.as_bytes()), ]; - match self.buffer.write_vectored(bufs) { - Ok(_) => return Ok(self.buffer.to_owned()), - Err(e) => return Err(e), - } + self.buffer.write_vectored(bufs)?; + Ok(self.buffer.to_owned()) } } \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 327ba56..3ab313b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,10 +17,8 @@ pub struct Sway { impl Sway { pub fn new(socket: &str) -> Result { - match UnixStream::connect(socket) { - Ok(stream) => return Ok(Sway{stream}), - Err(e) => return Err(e), - }; + let stream = UnixStream::connect(socket)?; + Ok(Sway{stream}) } /// Runs the payload as sway commands @@ -126,7 +124,7 @@ impl Sway { #[cfg(test)] mod tests { use crate::Sway; - use crate::i3msg::*; + use crate::i3msg::I3msg; use crate::ipc::*; fn sway_ipc() -> Sway {