Skip to content

Commit a9fd5a4

Browse files
zpg6thejpster
andauthored
Update src/lib.rs with suggestion
Co-authored-by: Jonathan 'theJPster' Pallant <[email protected]>
1 parent b3014cf commit a9fd5a4

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/lib.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,21 @@
4545
//!
4646
//! For writing files:
4747
//!
48-
//! ```rust,ignore
49-
//! let my_other_file = root_dir.open_file_in_dir("MY_DATA.CSV", embedded_sdmmc::Mode::ReadWriteCreateOrAppend)?;
50-
//! my_other_file.write(b"Timestamp,Signal,Value\n")?;
51-
//! my_other_file.write(b"2025-01-01T00:00:00Z,TEMP,25.0\n")?;
52-
//! my_other_file.write(b"2025-01-01T00:00:01Z,TEMP,25.1\n")?;
53-
//! my_other_file.write(b"2025-01-01T00:00:02Z,TEMP,25.2\n")?;
54-
//!
55-
//! // Don't forget to flush the file so that the directory entry is updated
56-
//! my_other_file.flush()?;
48+
//! ```rust
49+
//! use embedded_sdmmc::{BlockDevice, Directory, Error, Mode, TimeSource};
50+
//! fn write_file<D: BlockDevice, T: TimeSource, const DIRS: usize, const FILES: usize, const VOLUMES: usize>(
51+
//! root_dir: &mut Directory<D, T, DIRS, FILES, VOLUMES>,
52+
//! ) -> Result<(), Error<D::Error>>
53+
//! {
54+
//! let my_other_file = root_dir.open_file_in_dir("MY_DATA.CSV", Mode::ReadWriteCreateOrAppend)?;
55+
//! my_other_file.write(b"Timestamp,Signal,Value\n")?;
56+
//! my_other_file.write(b"2025-01-01T00:00:00Z,TEMP,25.0\n")?;
57+
//! my_other_file.write(b"2025-01-01T00:00:01Z,TEMP,25.1\n")?;
58+
//! my_other_file.write(b"2025-01-01T00:00:02Z,TEMP,25.2\n")?;
59+
//! // Don't forget to flush the file so that the directory entry is updated
60+
//! my_other_file.flush()?;
61+
//! Ok(())
62+
//! }
5763
//! ```
5864
//!
5965
//! ## Features

0 commit comments

Comments
 (0)