From 6cde4ee61eecaa95a926798012f44476f39c3cc7 Mon Sep 17 00:00:00 2001 From: "Chris West (Faux)" Date: Thu, 13 Jul 2017 17:49:50 +0100 Subject: [PATCH] fmt --- src/citer.rs | 22 +++++++++++++++++----- src/sane.rs | 48 +++++++++++------------------------------------- 2 files changed, 28 insertions(+), 42 deletions(-) diff --git a/src/citer.rs b/src/citer.rs index 89fa1ea..3cee8c0 100644 --- a/src/citer.rs +++ b/src/citer.rs @@ -10,20 +10,26 @@ pub trait RawIterator { } pub struct CIterator -where R: RawIterator { +where + R: RawIterator, +{ pub first: bool, pub raw: R, } impl Drop for CIterator -where R: RawIterator { +where + R: RawIterator, +{ fn drop(&mut self) { self.raw.release(); } } impl CIterator -where R: RawIterator { +where + R: RawIterator, +{ pub fn next(&mut self) -> Option { if self.raw.is_end() { return None; @@ -36,7 +42,11 @@ where R: RawIterator { self.first = false; // we don't want to observe the end marker - if self.raw.is_end() { None } else { Some(self.raw.as_view()) } + if self.raw.is_end() { + None + } else { + Some(self.raw.as_view()) + } } pub fn map(self, f: F) -> CMap @@ -49,7 +59,9 @@ where R: RawIterator { #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub struct CMap -where R: RawIterator { +where + R: RawIterator, +{ it: CIterator, f: F, } diff --git a/src/sane.rs b/src/sane.rs index 5821b8a..e9a02a9 100644 --- a/src/sane.rs +++ b/src/sane.rs @@ -26,12 +26,7 @@ impl Cache { /// /// See the module documentation for apologies about how this isn't an iterator. pub fn iter(&mut self) -> CIterator { - unsafe { - PkgIterator::new( - self, - raw::pkg_cache_pkg_iter(self.ptr), - ) - } + unsafe { PkgIterator::new(self, raw::pkg_cache_pkg_iter(self.ptr)) } } /// Find a package by name. It's not clear whether this picks a random arch, @@ -42,10 +37,7 @@ impl Cache { unsafe { let name = ffi::CString::new(name).unwrap(); let ptr = raw::pkg_cache_find_name(self.ptr, name.as_ptr()); - PkgIterator::new( - self, - ptr, - ) + PkgIterator::new(self, ptr) } } @@ -57,10 +49,7 @@ impl Cache { let name = ffi::CString::new(name).unwrap(); let arch = ffi::CString::new(arch).unwrap(); let ptr = raw::pkg_cache_find_name_arch(self.ptr, name.as_ptr(), arch.as_ptr()); - PkgIterator::new( - self, - ptr, - ) + PkgIterator::new(self, ptr) } } } @@ -76,10 +65,7 @@ impl<'c> PkgIterator<'c> { fn new(cache: &'c Cache, ptr: raw::PCache) -> citer::CIterator { citer::CIterator { first: true, - raw: PkgIterator{ - cache, - ptr - } + raw: PkgIterator { cache, ptr }, } } } @@ -95,15 +81,11 @@ impl<'c> citer::RawIterator for PkgIterator<'c> { type View = PkgView<'c>; fn is_end(&self) -> bool { - unsafe { - raw::pkg_iter_end(self.ptr) - } + unsafe { raw::pkg_iter_end(self.ptr) } } fn next(&mut self) { - unsafe { - raw::pkg_iter_next(self.ptr) - } + unsafe { raw::pkg_iter_next(self.ptr) } } fn as_view(&self) -> Self::View { @@ -116,9 +98,7 @@ impl<'c> citer::RawIterator for PkgIterator<'c> { } fn release(&mut self) { - unsafe { - raw::pkg_iter_release(self.ptr) - } + unsafe { raw::pkg_iter_release(self.ptr) } } } @@ -165,7 +145,7 @@ impl<'c> PkgView<'c> { raw: VerIterator { cache: PhantomData, ptr: unsafe { raw::pkg_iter_ver_iter(self.ptr) }, - } + }, } } } @@ -187,15 +167,11 @@ impl<'c> citer::RawIterator for VerIterator<'c> { type View = VerView<'c>; fn is_end(&self) -> bool { - unsafe { - raw::ver_iter_end(self.ptr) - } + unsafe { raw::ver_iter_end(self.ptr) } } fn next(&mut self) { - unsafe { - raw::ver_iter_next(self.ptr) - } + unsafe { raw::ver_iter_next(self.ptr) } } fn as_view(&self) -> Self::View { @@ -208,9 +184,7 @@ impl<'c> citer::RawIterator for VerIterator<'c> { } fn release(&mut self) { - unsafe { - raw::ver_iter_release(self.ptr) - } + unsafe { raw::ver_iter_release(self.ptr) } } }