Skip to content

Commit 5016cae

Browse files
Shivam Kalraojeda
authored andcommitted
rust: num: bounded: clean __new documentation and comments
Following commit 3a1ec42 ("rust: num: bounded: mark __new as unsafe"), remove the redundant paragraph in the documentation of __new now that the Safety section explicitly covers the requirement. Additionally, add an INVARIANT comment inside the function body where the Bounded instance is actually constructed to document that the type invariant is upheld. Suggested-by: Miguel Ojeda <ojeda@kernel.org> Link: https://lore.kernel.org/rust-for-linux/CANiq72mUCUh72BWP4eD1PTDpwdb1ML+Xgfom-Ys6thJooqQPwQ@mail.gmail.com/ Signed-off-by: Shivam Kalra <shivamklr@cock.li> Acked-by: Alexandre Courbot <acourbot@nvidia.com> Link: https://patch.msgid.link/20260123132132.53854-1-shivamklr@cock.li [ Reworded slightly. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent e440bc5 commit 5016cae

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

rust/kernel/num/bounded.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,6 @@ where
282282
/// All instances of [`Bounded`] must be created through this method as it enforces most of the
283283
/// type invariants.
284284
///
285-
/// The caller remains responsible for checking, either statically or dynamically, that `value`
286-
/// can be represented as a `T` using at most `N` bits.
287-
///
288285
/// # Safety
289286
///
290287
/// The caller must ensure that `value` can be represented within `N` bits.
@@ -297,6 +294,7 @@ where
297294
assert!(N <= T::BITS);
298295
}
299296

297+
// INVARIANT: The caller ensures `value` fits within `N` bits.
300298
Self(value)
301299
}
302300

0 commit comments

Comments
 (0)