Skip to content

Commit e52c2a4

Browse files
authored
README: update examples for #18; add doctests (#21)
* README: update examples for #18 * Add doctests for README
1 parent 1a6e7a7 commit e52c2a4

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let starting_lba = mbr.find_optimal_place(sectors)
6464
.expect("could not find a place to put the partition");
6565

6666
mbr[free_partition_number] = mbrman::MBRPartitionEntry {
67-
boot: false, // boot flag
67+
boot: mbrman::BOOT_INACTIVE, // boot flag
6868
first_chs: mbrman::CHS::empty(), // first CHS address (only useful for old computers)
6969
sys: 0x83, // Linux filesystem
7070
last_chs: mbrman::CHS::empty(), // last CHS address (only useful for old computers)
@@ -102,7 +102,7 @@ let mut mbr = mbrman::MBR::new_from(&mut cur, ss as u32, [0xff; 4])
102102
.expect("could not create partition table");
103103

104104
mbr[1] = mbrman::MBRPartitionEntry {
105-
boot: false, // boot flag
105+
boot: mbrman::BOOT_INACTIVE, // boot flag
106106
first_chs: mbrman::CHS::empty(), // first CHS address (only useful for old computers)
107107
sys: 0x0f, // extended partition with LBA
108108
last_chs: mbrman::CHS::empty(), // last CHS address (only useful for old computers)
@@ -132,7 +132,7 @@ let mut mbr = mbrman::MBR::new_from(&mut cur, ss as u32, [0xff; 4])
132132
.expect("could not create partition table");
133133

134134
mbr[1] = mbrman::MBRPartitionEntry {
135-
boot: false, // boot flag
135+
boot: mbrman::BOOT_INACTIVE, // boot flag
136136
first_chs: mbrman::CHS::empty(), // first CHS address (only useful for old computers)
137137
sys: 0x0f, // extended partition with LBA
138138
last_chs: mbrman::CHS::empty(), // last CHS address (only useful for old computers)
@@ -145,7 +145,7 @@ mbr.logical_partitions.push(
145145
mbrman::LogicalPartition {
146146
// this is the actual partition entry for the logical volume
147147
partition: mbrman::MBRPartitionEntry {
148-
boot: false,
148+
boot: mbrman::BOOT_INACTIVE,
149149
first_chs: mbrman::CHS::empty(),
150150
sys: 0x83,
151151
last_chs: mbrman::CHS::empty(),
@@ -156,8 +156,8 @@ mbr.logical_partitions.push(
156156
absolute_ebr_lba: 1,
157157
// the number of sectors in the first EBR is never known
158158
ebr_sectors: None,
159-
// this helper generates an empty boot sector in the EBR
160-
bootstrap_code: mbrman::BootstrapCode446::new(),
159+
// empty boot sector in the EBR
160+
bootstrap_code: [0; 446],
161161
// this is the absolute CHS address of the EBR (only used by old computers)
162162
ebr_first_chs: mbrman::CHS::empty(), // only for old computers
163163
// this is the absolute CHS address of the last EBR (only used by old computers)

src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,3 +1996,16 @@ mod tests {
19961996
));
19971997
}
19981998
}
1999+
2000+
#[cfg(doctest)]
2001+
mod test_readme {
2002+
// for Rust < 1.54
2003+
// https://blog.guillaume-gomez.fr/articles/2021-08-03+Improvements+for+%23%5Bdoc%5D+attributes+in+Rust
2004+
macro_rules! check_doc {
2005+
($x:expr) => {
2006+
#[doc = $x]
2007+
extern "C" {}
2008+
};
2009+
}
2010+
check_doc!(include_str!("../README.md"));
2011+
}

0 commit comments

Comments
 (0)