From d41aadcbf13033b7e598b4ad9f134dc3a7d39415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= <kornel@geekhood.net> Date: Tue, 22 Oct 2019 13:18:38 +0100 Subject: [PATCH] Edition idioms --- examples/compare.rs | 2 +- examples/gamma.rs | 2 +- examples/tags.rs | 2 +- examples/thread.rs | 4 ++-- src/error.rs | 2 +- src/locale.rs | 4 ++-- src/mlu.rs | 2 +- src/namedcolorlist.rs | 2 +- src/pipeline.rs | 4 ++-- src/profile.rs | 4 ++-- src/stage.rs | 2 +- src/tonecurve.rs | 2 +- src/transform.rs | 2 +- tests/transform.rs | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/compare.rs b/examples/compare.rs index e28f827..8365ad4 100644 --- a/examples/compare.rs +++ b/examples/compare.rs @@ -1,4 +1,4 @@ -extern crate lcms2; + use lcms2::*; use std::env; diff --git a/examples/gamma.rs b/examples/gamma.rs index 8a9eff4..eff6ee1 100644 --- a/examples/gamma.rs +++ b/examples/gamma.rs @@ -1,4 +1,4 @@ -extern crate lcms2; + use lcms2::*; #[repr(C)] diff --git a/examples/tags.rs b/examples/tags.rs index cf9d9f9..1d9d83e 100644 --- a/examples/tags.rs +++ b/examples/tags.rs @@ -1,4 +1,4 @@ -extern crate lcms2; + use lcms2::*; use std::env; diff --git a/examples/thread.rs b/examples/thread.rs index bf81f92..cbcfb72 100644 --- a/examples/thread.rs +++ b/examples/thread.rs @@ -1,4 +1,4 @@ -extern crate lcms2; + use lcms2::*; use std::thread; @@ -31,5 +31,5 @@ fn main() { let sync = Transform::new_flags_context(ThreadContext::new(), &profile, PixelFormat::RGB_8, &profile, PixelFormat::RGB_8, Intent::Saturation, Flags::NO_CACHE).unwrap(); let out = [0u8; 3]; sync.transform_pixels(&[[1u8,2,3]], &mut [out]); - let _: Box<Sync> = Box::new(sync); + let _: Box<dyn Sync> = Box::new(sync); } diff --git a/src/error.rs b/src/error.rs index 5b3343e..86f93fd 100644 --- a/src/error.rs +++ b/src/error.rs @@ -23,7 +23,7 @@ impl Error { pub type LCMSResult<T> = Result<T, Error>; impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.description()) } } diff --git a/src/locale.rs b/src/locale.rs index edc25e5..16ecce4 100644 --- a/src/locale.rs +++ b/src/locale.rs @@ -66,13 +66,13 @@ impl Default for Locale { } impl fmt::Debug for Locale { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { <Locale as fmt::Display>::fmt(self, f) } } impl fmt::Display for Locale { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for &c in self.language.iter().take_while(|&&c| c != 0) { f.write_char(c as u8 as char)?; } diff --git a/src/mlu.rs b/src/mlu.rs index f3646c7..8909929 100644 --- a/src/mlu.rs +++ b/src/mlu.rs @@ -146,7 +146,7 @@ impl MLURef { } impl fmt::Debug for MLURef { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let t = self.text(Locale::none()); write!(f, "MLU({:?} {:?})", if let Ok(ref t) = t { &t } else { "None" }, self.tanslations()) } diff --git a/src/namedcolorlist.rs b/src/namedcolorlist.rs index 34b4f8e..12d1c7e 100644 --- a/src/namedcolorlist.rs +++ b/src/namedcolorlist.rs @@ -93,7 +93,7 @@ impl NamedColorListRef { } impl<'a> fmt::Debug for NamedColorListRef { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(c) = self.get(0) { write!(f, "NamedColorList({} colors: {}{}{}, etc.)", self.len(), c.prefix, c.name, c.suffix) } else { diff --git a/src/pipeline.rs b/src/pipeline.rs index 040253e..6306529 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -56,7 +56,7 @@ impl PipelineRef { } } - pub fn stages(&self) -> StagesIter { + pub fn stages(&self) -> StagesIter<'_> { StagesIter(self.first_stage()) } @@ -89,7 +89,7 @@ impl PipelineRef { } impl fmt::Debug for PipelineRef { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Pipeline({}->{}ch, {} stages)", self.input_channels(), self.output_channels(), self.stage_count()) } } diff --git a/src/profile.rs b/src/profile.rs index de29608..377d885 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -331,11 +331,11 @@ impl<Ctx: Context> Profile<Ctx> { unsafe { ffi::cmsIsTag(self.handle, sig) != 0 } } - pub fn read_tag(&self, sig: TagSignature) -> Tag { + pub fn read_tag(&self, sig: TagSignature) -> Tag<'_> { unsafe { Tag::new(sig, ffi::cmsReadTag(self.handle, sig) as *const u8) } } - pub fn write_tag(&mut self, sig: TagSignature, tag: Tag) -> bool { + pub fn write_tag(&mut self, sig: TagSignature, tag: Tag<'_>) -> bool { unsafe { ffi::cmsWriteTag(self.handle, sig, tag.data_for_signature(sig) as *const _) != 0 } diff --git a/src/stage.rs b/src/stage.rs index 6bbf6a6..fdc25e0 100644 --- a/src/stage.rs +++ b/src/stage.rs @@ -109,7 +109,7 @@ impl<'a> Iterator for StagesIter<'a> { } impl fmt::Debug for StageRef { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Stage({:?})", self.stage_type()) } } diff --git a/src/tonecurve.rs b/src/tonecurve.rs index b8ee265..09d164c 100644 --- a/src/tonecurve.rs +++ b/src/tonecurve.rs @@ -151,7 +151,7 @@ impl ToneCurveRef { } impl fmt::Debug for ToneCurveRef { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ToneCurve({} entries, gamma ~{:.1})", self.estimated_entries().len(), self.estimated_gamma(1.).unwrap_or(0.)) } } diff --git a/src/transform.rs b/src/transform.rs index 51fe584..c2ea818 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -131,7 +131,7 @@ impl<InputPixelFormat: Copy + Clone, OutputPixelFormat: Copy + Clone, Ctx: Conte Err(Error::ObjectCreationError) } else { Ok(Transform { - handle: handle, + handle, _from: Self::check_format::<InputPixelFormat>(in_format, true), _to: Self::check_format::<OutputPixelFormat>(out_format, false), _context_ref: PhantomData, diff --git a/tests/transform.rs b/tests/transform.rs index abcea48..4b5a24c 100644 --- a/tests/transform.rs +++ b/tests/transform.rs @@ -1,4 +1,4 @@ -extern crate lcms2; + use lcms2::*; const PROFILE: &'static [u8] = include_bytes!("tinysrgb.icc"); -- GitLab