mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 20:54:03 +02:00
rust: impl_flags: use bit helper in example
Use bit_u32() instead of open-coding shifts in the impl_flags! example. This demonstrates the checked bit helper and ensures that bit positions remain within the underlying u32 type. Suggested-by: Miguel Ojeda <ojeda@kernel.org> Link: https://github.com/Rust-for-Linux/linux/issues/1244 Assisted-by: OpenCode:openai/gpt-5.6-sol Signed-off-by: Kosumi Chan <chankocyo@gmail.com> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/rust-for-linux/2026071054-hazing-antirust-8e40@gregkh/ Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Link: https://patch.msgid.link/20260711082327.3062227-1-chankocyo@gmail.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
168b4f9aa5
commit
39a309f432
|
|
@ -19,7 +19,10 @@
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use kernel::impl_flags;
|
||||
/// use kernel::{
|
||||
/// bits::bit_u32,
|
||||
/// impl_flags, //
|
||||
/// };
|
||||
///
|
||||
/// impl_flags!(
|
||||
/// /// Represents multiple permissions.
|
||||
|
|
@ -30,13 +33,13 @@
|
|||
/// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
/// pub enum Permission {
|
||||
/// /// Read permission.
|
||||
/// Read = 1 << 0,
|
||||
/// Read = bit_u32(0),
|
||||
///
|
||||
/// /// Write permission.
|
||||
/// Write = 1 << 1,
|
||||
/// Write = bit_u32(1),
|
||||
///
|
||||
/// /// Execute permission.
|
||||
/// Execute = 1 << 2,
|
||||
/// Execute = bit_u32(2),
|
||||
/// }
|
||||
/// );
|
||||
///
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user