Skip to content

Commit 06ee762

Browse files
committed
Fix naming/refactoring misses
1 parent 192e442 commit 06ee762

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

crates/bevy_ecs/src/identifier/bits.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ bitflags! {
1111
/// [`super::IdKind::Placeholder`] or [`super::IdKind::Entity`].
1212
const IS_PLACEHOLDER = 0b1000_0000_0000_0000_0000_0000_0000_0000;
1313
/// Flag for determining whether the [`super::Identifier`] is in a
14-
/// `toggeable` state or not.
14+
/// `togglable` state or not.
1515
const IS_TOGGLABLE = 0b0100_0000_0000_0000_0000_0000_0000_0000;
1616

1717
const _ = !0;
@@ -36,7 +36,7 @@ mod tests {
3636
use super::*;
3737

3838
#[test]
39-
fn smoke_test() {
39+
fn flag_bits_are_correctly_determined() {
4040
// Both flag bits are set
4141
let bits: u32 = 0xC0FF_EEEE;
4242

crates/bevy_ecs/src/identifier/masks.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ mod tests {
139139
// Excludes the most significant bit as that is a flag bit.
140140
assert_eq!(IdentifierMask::extract_value_from_high(high), HIGH_MASK);
141141

142-
// Start bit and end bit are ones.
142+
// Start two bits and end bit are ones.
143143
let high: u32 = 0xC000_0001;
144144

145145
assert_eq!(IdentifierMask::extract_value_from_high(high), 0x0000_0001);
@@ -152,12 +152,12 @@ mod tests {
152152

153153
#[test]
154154
fn pack_flag_bits() {
155-
// All bits are ones expect the 2 most significant bits, which are zero
155+
// All bits are ones except the 2 most significant bits, which are zero
156156
let high: u32 = 0x7FFF_FFFF;
157157

158158
assert_eq!(
159159
IdentifierMask::pack_flags_into_high(high, IdentifierFlagBits::IS_PLACEHOLDER),
160-
// The IS_HIDDEN flag is cleared and the IS_PLACEHOLDER flag is enabled
160+
// The IS_TOGGLABLE flag is cleared and the IS_PLACEHOLDER flag is enabled
161161
0xBFFF_FFFF
162162
);
163163

crates/bevy_ecs/src/identifier/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct Identifier {
3131
}
3232

3333
impl Identifier {
34-
/// Construct a new [`Identifier`]. The `high` parameter is masked so to pack
34+
/// Construct a new [`Identifier`]. The `high` parameter is masked so we can pack
3535
/// the high value and bit flags into the same field.
3636
#[inline(always)]
3737
pub const fn new(
@@ -95,7 +95,7 @@ impl Identifier {
9595
IdentifierMask::extract_kind_from_high(self.high.get())
9696
}
9797

98-
/// Returns with the [`Identifier`] is in a `hidden` state.
98+
/// Returns with the [`Identifier`] is in a `togglable` state.
9999
#[inline(always)]
100100
pub const fn is_togglable(self) -> bool {
101101
self.flags().contains(IdentifierFlagBits::IS_TOGGLABLE)
@@ -114,16 +114,16 @@ impl Identifier {
114114
IdentifierMask::extract_flags_from_high(self.high.get())
115115
}
116116

117-
/// Returns a `hidden` [`Identifier`].
117+
/// Returns a `togglable` [`Identifier`].
118118
#[inline(always)]
119119
#[must_use]
120-
pub const fn set_hidden(self, state: bool) -> Identifier {
120+
pub const fn set_togglable(self, state: bool) -> Identifier {
121121
Self {
122122
low: self.low,
123123
// SAFETY: the high component will always be non-zero due to either the
124124
// placeholder flag or the value component not being modified and either
125125
// one guaranteed to be one due to Identifier being initialised with the
126-
// correct invariants checked. As such, modifying the hidden bit will
126+
// correct invariants checked. As such, modifying the togglable bit will
127127
// never result in a zero value.
128128
high: unsafe {
129129
NonZeroU32::new_unchecked(IdentifierMask::set_togglable_flag_in_high(
@@ -275,7 +275,7 @@ mod tests {
275275

276276
assert!(id.is_togglable());
277277

278-
let id = id.set_hidden(false);
278+
let id = id.set_togglable(false);
279279

280280
assert_eq!(id.to_bits(), 0x3FFF_FFFF_0000_000C);
281281
assert!(!id.is_togglable());

0 commit comments

Comments
 (0)