Skip to content

Commit e4206df

Browse files
committed
Removed count_ones in favor of is_power_of_two
1 parent fba8854 commit e4206df

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/boot_sector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl BiosParameterBlock {
125125
}
126126

127127
fn validate_bytes_per_sector<E: IoError>(&self) -> Result<(), Error<E>> {
128-
if self.bytes_per_sector.count_ones() != 1 {
128+
if !self.bytes_per_sector.is_power_of_two() {
129129
error!(
130130
"invalid bytes_per_sector value in BPB: expected a power of two but got {}",
131131
self.bytes_per_sector
@@ -143,7 +143,7 @@ impl BiosParameterBlock {
143143
}
144144

145145
fn validate_sectors_per_cluster<E: IoError>(&self) -> Result<(), Error<E>> {
146-
if self.sectors_per_cluster.count_ones() != 1 {
146+
if !self.sectors_per_cluster.is_power_of_two() {
147147
error!(
148148
"invalid sectors_per_cluster value in BPB: expected a power of two but got {}",
149149
self.sectors_per_cluster

src/fs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ impl FormatVolumeOptions {
981981
#[must_use]
982982
pub fn bytes_per_cluster(mut self, bytes_per_cluster: u32) -> Self {
983983
assert!(
984-
bytes_per_cluster.count_ones() == 1 && bytes_per_cluster >= 512,
984+
bytes_per_cluster.is_power_of_two() && bytes_per_cluster >= 512,
985985
"Invalid bytes_per_cluster"
986986
);
987987
self.bytes_per_cluster = Some(bytes_per_cluster);
@@ -1011,7 +1011,7 @@ impl FormatVolumeOptions {
10111011
#[must_use]
10121012
pub fn bytes_per_sector(mut self, bytes_per_sector: u16) -> Self {
10131013
assert!(
1014-
bytes_per_sector.count_ones() == 1 && bytes_per_sector >= 512,
1014+
bytes_per_sector.is_power_of_two() && bytes_per_sector >= 512,
10151015
"Invalid bytes_per_sector"
10161016
);
10171017
self.bytes_per_sector = bytes_per_sector;

0 commit comments

Comments
 (0)