From 5574c2af73da30d75c042777c6227e452de2d177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Harabie=C5=84?= Date: Wed, 13 Jun 2018 23:26:13 +0200 Subject: [PATCH] Simplify examples using new FileSystem struct definition --- examples/cat.rs | 4 ++-- examples/ls.rs | 4 ++-- examples/partition.rs | 4 ++-- examples/write.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/cat.rs b/examples/cat.rs index fbf8be8..e9ea2bf 100644 --- a/examples/cat.rs +++ b/examples/cat.rs @@ -8,8 +8,8 @@ use fatfs::{FileSystem, FsOptions, BufStream}; fn main() -> io::Result<()> { let file = File::open("resources/fat32.img")?; - let mut buf_rdr = BufStream::new(file); - let fs = FileSystem::new(&mut buf_rdr, FsOptions::new())?; + let buf_rdr = BufStream::new(file); + let fs = FileSystem::new(buf_rdr, FsOptions::new())?; let root_dir = fs.root_dir(); let mut file = root_dir.open_file(&env::args().nth(1).unwrap())?; let mut buf = vec![]; diff --git a/examples/ls.rs b/examples/ls.rs index d519388..2fdaf00 100644 --- a/examples/ls.rs +++ b/examples/ls.rs @@ -25,8 +25,8 @@ fn format_file_size(size: u64) -> String { fn main() -> io::Result<()> { let file = File::open("resources/fat32.img")?; - let mut buf_rdr = BufStream::new(file); - let fs = FileSystem::new(&mut buf_rdr, FsOptions::new())?; + let buf_rdr = BufStream::new(file); + let fs = FileSystem::new(buf_rdr, FsOptions::new())?; let root_dir = fs.root_dir(); let dir = match env::args().nth(1) { None => root_dir, diff --git a/examples/partition.rs b/examples/partition.rs index 0c8598c..b8e2ff0 100644 --- a/examples/partition.rs +++ b/examples/partition.rs @@ -74,9 +74,9 @@ fn main() -> io::Result<()> { // Create partition using provided start address and size in bytes let partition = Partition::::new(file, first_lba, last_lba - first_lba + 1)?; // Create buffered stream to optimize file access - let mut buf_rdr = BufStream::new(partition); + let buf_rdr = BufStream::new(partition); // Finally initialize filesystem struct using provided partition - let fs = FileSystem::new(&mut buf_rdr, FsOptions::new())?; + let fs = FileSystem::new(buf_rdr, FsOptions::new())?; // Read and display volume label println!("Volume Label: {}", fs.volume_label()); // other operations... diff --git a/examples/write.rs b/examples/write.rs index 9fe01fc..ee23cff 100644 --- a/examples/write.rs +++ b/examples/write.rs @@ -13,9 +13,9 @@ fn main() -> io::Result<()> { return Err(err); } }; - let mut buf_stream = BufStream::new(img_file); + let buf_stream = BufStream::new(img_file); let options = FsOptions::new().update_accessed_date(true); - let fs = FileSystem::new(&mut buf_stream, options)?; + let fs = FileSystem::new(buf_stream, options)?; let mut file = fs.root_dir().create_file("hello.txt")?; file.write_all(b"Hello World!")?; Ok(())