From c1b9336de4028cdf6a9025b2f5f14f3699272fe2 Mon Sep 17 00:00:00 2001 From: c Date: Tue, 6 Jun 2023 17:25:51 +0200 Subject: [PATCH] Fix clippy warnings --- src/internal/path.rs | 10 +++++----- src/internal/stream.rs | 2 +- tests/basic.rs | 8 ++++---- tests/malformed.rs | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/internal/path.rs b/src/internal/path.rs index d1e1b65..c1b9ae6 100644 --- a/src/internal/path.rs +++ b/src/internal/path.rs @@ -123,7 +123,7 @@ mod tests { #[test] fn absolute_path_is_valid() { assert_eq!( - name_chain_from_path(&Path::new("/foo/bar/baz/")).unwrap(), + name_chain_from_path(Path::new("/foo/bar/baz/")).unwrap(), vec!["foo", "bar", "baz"] ); } @@ -131,7 +131,7 @@ mod tests { #[test] fn relative_path_is_valid() { assert_eq!( - name_chain_from_path(&Path::new("foo/bar/baz")).unwrap(), + name_chain_from_path(Path::new("foo/bar/baz")).unwrap(), vec!["foo", "bar", "baz"] ); } @@ -139,7 +139,7 @@ mod tests { #[test] fn path_with_parents_is_valid() { assert_eq!( - name_chain_from_path(&Path::new("foo/bar/../baz")).unwrap(), + name_chain_from_path(Path::new("foo/bar/../baz")).unwrap(), vec!["foo", "baz"] ); } @@ -147,13 +147,13 @@ mod tests { #[test] #[should_panic(expected = "Invalid path (must be within root)")] fn parent_of_root_is_invalid() { - name_chain_from_path(&Path::new("foo/../../baz")).unwrap(); + name_chain_from_path(Path::new("foo/../../baz")).unwrap(); } #[test] fn canonical_path_is_absolute() { let path = Path::new("foo/bar/../baz"); - let names = name_chain_from_path(&path).unwrap(); + let names = name_chain_from_path(path).unwrap(); assert_eq!(path_from_name_chain(&names), PathBuf::from("/foo/baz")); } } diff --git a/src/internal/stream.rs b/src/internal/stream.rs index 1b820ce..bf2bdde 100644 --- a/src/internal/stream.rs +++ b/src/internal/stream.rs @@ -1,4 +1,4 @@ -use crate::internal::{consts, MiniAllocator, ObjType, SectorInit, Timestamp}; +use crate::internal::{consts, MiniAllocator, ObjType, SectorInit}; use std::cell::RefCell; use std::io::{self, BufRead, Read, Seek, SeekFrom, Write}; use std::rc::{Rc, Weak}; diff --git a/tests/basic.rs b/tests/basic.rs index e506009..75434bf 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -643,7 +643,7 @@ fn truncate_stream() { assert_eq!(stream.seek(SeekFrom::Start(6000)).unwrap(), 6000); stream.set_len(7000).unwrap(); assert_eq!(stream.len(), 7000); - assert_eq!(stream.seek(SeekFrom::Current(0)).unwrap(), 6000); + assert_eq!(stream.stream_position().unwrap(), 6000); stream.set_len(5000).unwrap(); assert_eq!(stream.len(), 5000); stream.write_all(&vec![b'x'; 1000]).unwrap(); @@ -672,13 +672,13 @@ fn extend_stream() { assert_eq!(stream.seek(SeekFrom::Start(1000)).unwrap(), 1000); stream.write_all(&vec![b'y'; 500]).unwrap(); assert_eq!(stream.len(), 2000); - assert_eq!(stream.seek(SeekFrom::Current(0)).unwrap(), 1500); + assert_eq!(stream.stream_position().unwrap(), 1500); stream.set_len(5000).unwrap(); assert_eq!(stream.len(), 5000); - assert_eq!(stream.seek(SeekFrom::Current(0)).unwrap(), 1500); + assert_eq!(stream.stream_position().unwrap(), 1500); stream.write_all(&vec![b'z'; 500]).unwrap(); assert_eq!(stream.len(), 5000); - assert_eq!(stream.seek(SeekFrom::Current(0)).unwrap(), 2000); + assert_eq!(stream.stream_position().unwrap(), 2000); } let cursor = comp.into_inner(); diff --git a/tests/malformed.rs b/tests/malformed.rs index b1ef561..db9f645 100644 --- a/tests/malformed.rs +++ b/tests/malformed.rs @@ -31,7 +31,7 @@ where // Checks to see if a file can be walked over and read properly, or fail if it can not be read fn can_read(path: &Path) { - let data = std::fs::read(&path).unwrap(); + let data = std::fs::read(path).unwrap(); let cursor = Cursor::new(data); let mut cfb = match CompoundFile::open(cursor) {