summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2020-05-16 17:19:00 -0600
committerAlan Somers <asomers@gmail.com>2020-06-27 17:36:46 -0600
commite6e25ec8cac2635b556355ec6a00bc1cc8d4fa6e (patch)
treecb7a6dda08f51eabb1d4b31f7aebd681d64286da /src
parent729e7828263fec48d80ef6cc68b14b96da0206e1 (diff)
downloadnix-e6e25ec8cac2635b556355ec6a00bc1cc8d4fa6e.zip
Prefer to pass Inotify by value instead of by reference
It's small and `Copy`, so pass by value is more efficient. This is technically a breaking change, but most code should compile without changes.
Diffstat (limited to 'src')
-rw-r--r--src/sys/inotify.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/sys/inotify.rs b/src/sys/inotify.rs
index e73c3fcb..4880a4a5 100644
--- a/src/sys/inotify.rs
+++ b/src/sys/inotify.rs
@@ -131,7 +131,7 @@ impl Inotify {
/// Returns a watch descriptor. This is not a File Descriptor!
///
/// For more information see, [inotify_add_watch(2)](http://man7.org/linux/man-pages/man2/inotify_add_watch.2.html).
- pub fn add_watch<P: ?Sized + NixPath>(&self,
+ pub fn add_watch<P: ?Sized + NixPath>(self,
path: &P,
mask: AddWatchFlags)
-> Result<WatchDescriptor>
@@ -152,14 +152,14 @@ impl Inotify {
///
/// For more information see, [inotify_rm_watch(2)](http://man7.org/linux/man-pages/man2/inotify_rm_watch.2.html).
#[cfg(target_os = "linux")]
- pub fn rm_watch(&self, wd: WatchDescriptor) -> Result<()> {
+ pub fn rm_watch(self, wd: WatchDescriptor) -> Result<()> {
let res = unsafe { libc::inotify_rm_watch(self.fd, wd.wd) };
Errno::result(res).map(drop)
}
#[cfg(target_os = "android")]
- pub fn rm_watch(&self, wd: WatchDescriptor) -> Result<()> {
+ pub fn rm_watch(self, wd: WatchDescriptor) -> Result<()> {
let res = unsafe { libc::inotify_rm_watch(self.fd, wd.wd as u32) };
Errno::result(res).map(drop)
@@ -171,7 +171,7 @@ impl Inotify {
///
/// Returns as many events as available. If the call was non blocking and no
/// events could be read then the EAGAIN error is returned.
- pub fn read_events(&self) -> Result<Vec<InotifyEvent>> {
+ pub fn read_events(self) -> Result<Vec<InotifyEvent>> {
let header_size = size_of::<libc::inotify_event>();
const BUFSIZ: usize = 4096;
let mut buffer = [0u8; BUFSIZ];