You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
unsafe from_bits_unchecked() allows creating instances with extra bits. The caller of the bitflags! macro can decide if this is allowed for their type. Let's assume it is for Example. I checked the provided methods for surprising interactions with extra bits, and found (only) this:
is_all() returns false when there are more than "all" flags. This does not match the documentation:
Returns true if all flags are currently set.
Should we update the documentation or the implementation?
use bitflags::bitflags;bitflags!{structExample: u32{constA = 1;
}}fnmain(){unsafe{assert!(Example::from_bits_unchecked(1).is_all());// trueassert!(Example::from_bits_unchecked(3).is_all());// false}}
unsafe from_bits_unchecked()
allows creating instances with extra bits. The caller of thebitflags!
macro can decide if this is allowed for their type. Let's assume it is forExample
. I checked the provided methods for surprising interactions with extra bits, and found (only) this:is_all()
returns false when there are more than "all" flags. This does not match the documentation:Should we update the documentation or the implementation?
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cda2672387dd0ff4ba629b1317a9c57c
The text was updated successfully, but these errors were encountered: