From 1656540eac54a99d3cb82555da6a8a2b6de398b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Harabie=C5=84?= Date: Wed, 6 Jun 2018 17:16:32 +0200 Subject: [PATCH] Simplify code by using Self in return type --- src/dir.rs | 8 ++++---- src/dir_entry.rs | 4 ++-- src/fs.rs | 2 +- src/table.rs | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/dir.rs b/src/dir.rs index f44f564..e65a851 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -87,7 +87,7 @@ pub struct Dir<'a, 'b: 'a> { } impl <'a, 'b> Dir<'a, 'b> { - pub(crate) fn new(stream: DirRawStream<'a, 'b>, fs: FileSystemRef<'a, 'b>) -> Dir<'a, 'b> { + pub(crate) fn new(stream: DirRawStream<'a, 'b>, fs: FileSystemRef<'a, 'b>) -> Self { Dir { stream, fs } } @@ -115,7 +115,7 @@ impl <'a, 'b> Dir<'a, 'b> { } /// Opens existing directory - pub fn open_dir(&mut self, path: &str) -> io::Result> { + pub fn open_dir(&mut self, path: &str) -> io::Result { let (name, rest_opt) = split_path(path); let e = self.find_entry(name, None)?; match rest_opt { @@ -158,7 +158,7 @@ impl <'a, 'b> Dir<'a, 'b> { } /// Creates new directory or opens existing. - pub fn create_dir(&mut self, path: &str) -> io::Result> { + pub fn create_dir(&mut self, path: &str) -> io::Result { let (name, rest_opt) = split_path(path); match rest_opt { // path contains more than 1 component @@ -499,7 +499,7 @@ struct LongNameBuilder { #[cfg(feature = "alloc")] impl LongNameBuilder { - fn new() -> LongNameBuilder { + fn new() -> Self { LongNameBuilder { buf: Vec::::new(), chksum: 0, diff --git a/src/dir_entry.rs b/src/dir_entry.rs index fe63413..13866d4 100644 --- a/src/dir_entry.rs +++ b/src/dir_entry.rs @@ -357,7 +357,7 @@ impl DirEntryData { } } - pub(crate) fn deserialize(rdr: &mut Read) -> io::Result { + pub(crate) fn deserialize(rdr: &mut Read) -> io::Result { let mut name = [0; 11]; match rdr.read_exact(&mut name) { Err(ref err) if err.kind() == io::ErrorKind::UnexpectedEof => { @@ -531,7 +531,7 @@ pub(crate) struct DirEntryEditor { } impl DirEntryEditor { - fn new(data: DirFileEntryData, pos: u64) -> DirEntryEditor { + fn new(data: DirFileEntryData, pos: u64) -> Self { DirEntryEditor { data, pos, dirty: false, diff --git a/src/fs.rs b/src/fs.rs index 5236f86..009f928 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -365,7 +365,7 @@ impl <'a> FileSystem<'a> { /// /// Note: creating multiple filesystem objects with one underlying device/disk image can /// cause filesystem corruption. - pub fn new(disk: &'a mut T, options: FsOptions) -> io::Result> { + pub fn new(disk: &'a mut T, options: FsOptions) -> io::Result { // Make sure given image is not seeked debug_assert!(disk.seek(SeekFrom::Current(0))? == 0); diff --git a/src/table.rs b/src/table.rs index 7c088b4..e69988c 100644 --- a/src/table.rs +++ b/src/table.rs @@ -334,8 +334,7 @@ pub(crate) struct ClusterIterator<'a, 'b: 'a> { } impl <'a, 'b> ClusterIterator<'a, 'b> { - pub(crate) fn new(fat: DiskSlice<'a, 'b>, fat_type: FatType, cluster: u32) - -> ClusterIterator<'a, 'b> { + pub(crate) fn new(fat: DiskSlice<'a, 'b>, fat_type: FatType, cluster: u32) -> Self { ClusterIterator { fat, fat_type,