pub struct GameModsLegacy(/* private fields */);Expand description
Lightweight bitflag type for legacy mods.
§Example
use rosu_mods::GameModsLegacy;
let nomod = GameModsLegacy::default();
assert_eq!(nomod, GameModsLegacy::NoMod);
// Created via bit operations or from a u32
let hdhr_1 = GameModsLegacy::Hidden | GameModsLegacy::HardRock;
let hdhr_2 = GameModsLegacy::from_bits(8 + 16);
assert_eq!(hdhr_1, hdhr_2);
// Various methods for convenience like `contains` and `intersects`.
let ezhdpf = GameModsLegacy::Easy | GameModsLegacy::Hidden | GameModsLegacy::Perfect;
assert!(!ezhdpf.contains(GameModsLegacy::HardRock));
let hdpf = GameModsLegacy::Hidden | GameModsLegacy::Perfect;
assert!(ezhdpf.intersects(hdpf));
// Parsing a `&str`
let hdhrdt = "dthdhr".parse::<GameModsLegacy>().unwrap();
assert_eq!(hdhrdt.bits(), 8 + 16 + 64);
// The Display implementation combines all acronyms
assert_eq!(hdhrdt.to_string(), "HDHRDT".to_string());
// Has an iterator type
let mut iter = GameModsLegacy::from_bits(536871512).iter();
assert_eq!(iter.next(), Some(GameModsLegacy::Hidden));
assert_eq!(iter.next(), Some(GameModsLegacy::HardRock));
assert_eq!(iter.next(), Some(GameModsLegacy::Nightcore));
assert_eq!(iter.next(), Some(GameModsLegacy::ScoreV2));
assert_eq!(iter.next(), None);Implementations§
Source§impl GameModsLegacy
impl GameModsLegacy
pub const NoMod: Self
pub const NoFail: Self
pub const Easy: Self
pub const TouchDevice: Self
pub const Hidden: Self
pub const HardRock: Self
pub const SuddenDeath: Self
pub const DoubleTime: Self
pub const Relax: Self
pub const HalfTime: Self
pub const Nightcore: Self
pub const Flashlight: Self
pub const Autoplay: Self
pub const SpunOut: Self
pub const Autopilot: Self
pub const Perfect: Self
pub const Key4: Self
pub const Key5: Self
pub const Key6: Self
pub const Key7: Self
pub const Key8: Self
pub const FadeIn: Self
pub const Random: Self
pub const Cinema: Self
pub const Target: Self
pub const Key9: Self
pub const KeyCoop: Self
pub const Key1: Self
pub const Key3: Self
pub const Key2: Self
pub const ScoreV2: Self
pub const Mirror: Self
Source§impl GameModsLegacy
impl GameModsLegacy
Sourcepub const fn clock_rate(self) -> f64
pub const fn clock_rate(self) -> f64
Returns the clock rate for the mods i.e. 1.5 for DT, 0.75 for HT, and 1.0 otherwise.
Sourcepub const fn len(self) -> usize
pub const fn len(self) -> usize
Returns the amount of contained mods.
§Example
use rosu_mods::GameModsLegacy;
assert_eq!(GameModsLegacy::NoMod.len(), 0);
let mods = GameModsLegacy::from_bits(8 + 16 + 64 + 128);
assert_eq!(mods.len(), 4);Sourcepub fn iter(self) -> GameModsLegacyIter ⓘ
pub fn iter(self) -> GameModsLegacyIter ⓘ
Returns an iterator over GameModsLegacy.
§Example
use rosu_mods::GameModsLegacy;
let mut iter = GameModsLegacy::from_bits(8 + 16 + 64 + 128).iter();
assert_eq!(iter.next(), Some(GameModsLegacy::Hidden));
assert_eq!(iter.next(), Some(GameModsLegacy::HardRock));
assert_eq!(iter.next(), Some(GameModsLegacy::DoubleTime));
assert_eq!(iter.next(), Some(GameModsLegacy::Relax));
assert_eq!(iter.next(), None);
let mut iter = GameModsLegacy::NoMod.iter();
assert_eq!(iter.next(), Some(GameModsLegacy::NoMod));
assert_eq!(iter.next(), None);Sourcepub fn to_intermode(self) -> GameModsIntermode
pub fn to_intermode(self) -> GameModsIntermode
Convert GameModsLegacy to GameModsIntermode.
Source§impl GameModsLegacy
impl GameModsLegacy
Sourcepub const fn bits(self) -> u32
pub const fn bits(self) -> u32
Get the underlying bits value.
The returned value is exactly the bits set in this flags value.
Sourcepub const fn try_from_bits(bits: u32) -> Option<Self>
pub const fn try_from_bits(bits: u32) -> Option<Self>
Convert from a bits value.
This method will return None if any unknown bits are set.
Sourcepub const fn from_bits(bits: u32) -> Self
pub const fn from_bits(bits: u32) -> Self
Convert from a bits value, unsetting any unknown bits.
Sourcepub const fn from_bits_retain(bits: u32) -> Self
pub const fn from_bits_retain(bits: u32) -> Self
Convert from a bits value exactly.
Unknown bits are retained.
Sourcepub const fn intersects(self, other: Self) -> bool
pub const fn intersects(self, other: Self) -> bool
Whether any set bits in a source flags value are also set in a target flags value.
Sourcepub const fn contains(self, other: Self) -> bool
pub const fn contains(self, other: Self) -> bool
Whether all set bits in a source flags value are also set in a target flags value.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
The bitwise or (|) of the bits in two flags values.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
remove won’t truncate other, but the ! operator will.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
The bitwise and (&) of the bits in two flags values.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
The bitwise or (|) of the bits in two flags values.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
The bitwise exclusive-or (^) of the bits in two flags values.
Trait Implementations§
Source§impl Archive for GameModsLegacy
Available on crate feature rkyv only.
impl Archive for GameModsLegacy
rkyv only.Source§type Archived = <u32 as Archive>::Archived
type Archived = <u32 as Archive>::Archived
Source§type Resolver = ()
type Resolver = ()
Source§fn resolve(&self, resolver: (), out: Place<Self::Archived>)
fn resolve(&self, resolver: (), out: Place<Self::Archived>)
Source§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize. Read moreSource§impl Binary for GameModsLegacy
impl Binary for GameModsLegacy
Source§impl BitAnd for GameModsLegacy
impl BitAnd for GameModsLegacy
Source§impl BitAndAssign for GameModsLegacy
impl BitAndAssign for GameModsLegacy
Source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
The bitwise and (&) of the bits in two flags values.
Source§impl BitOr for GameModsLegacy
impl BitOr for GameModsLegacy
Source§fn bitor(self, other: GameModsLegacy) -> Self
fn bitor(self, other: GameModsLegacy) -> Self
The bitwise or (|) of the bits in two flags values.
Source§type Output = GameModsLegacy
type Output = GameModsLegacy
| operator.Source§impl BitOrAssign for GameModsLegacy
impl BitOrAssign for GameModsLegacy
Source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
The bitwise or (|) of the bits in two flags values.
Source§impl BitXor for GameModsLegacy
impl BitXor for GameModsLegacy
Source§impl Clone for GameModsLegacy
impl Clone for GameModsLegacy
Source§fn clone(&self) -> GameModsLegacy
fn clone(&self) -> GameModsLegacy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GameModsLegacy
impl Debug for GameModsLegacy
Source§impl Default for GameModsLegacy
impl Default for GameModsLegacy
Source§fn default() -> GameModsLegacy
fn default() -> GameModsLegacy
Source§impl<'de> Deserialize<'de> for GameModsLegacy
Available on crate feature serde only.
impl<'de> Deserialize<'de> for GameModsLegacy
serde only.Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Source§impl<D: Fallible + ?Sized> Deserialize<GameModsLegacy, D> for ArchivedU32
Available on crate feature rkyv only.
impl<D: Fallible + ?Sized> Deserialize<GameModsLegacy, D> for ArchivedU32
rkyv only.Source§fn deserialize(&self, _: &mut D) -> Result<GameModsLegacy, D::Error>
fn deserialize(&self, _: &mut D) -> Result<GameModsLegacy, D::Error>
Source§impl Display for GameModsLegacy
impl Display for GameModsLegacy
Source§impl Extend<GameModsLegacy> for GameModsLegacy
impl Extend<GameModsLegacy> for GameModsLegacy
Source§fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
The bitwise or (|) of the bits in each flags value.
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl From<GameModsLegacy> for GameModsIntermode
impl From<GameModsLegacy> for GameModsIntermode
Source§fn from(mods: GameModsLegacy) -> Self
fn from(mods: GameModsLegacy) -> Self
Source§impl From<GameModsLegacy> for u32
impl From<GameModsLegacy> for u32
Source§fn from(mods: GameModsLegacy) -> Self
fn from(mods: GameModsLegacy) -> Self
Source§impl FromIterator<GameModsLegacy> for GameModsLegacy
impl FromIterator<GameModsLegacy> for GameModsLegacy
Source§fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
The bitwise or (|) of the bits in each flags value.
Source§impl FromStr for GameModsLegacy
impl FromStr for GameModsLegacy
Source§impl Hash for GameModsLegacy
impl Hash for GameModsLegacy
Source§impl IntoIterator for GameModsLegacy
impl IntoIterator for GameModsLegacy
Source§impl Ord for GameModsLegacy
impl Ord for GameModsLegacy
Source§fn cmp(&self, other: &GameModsLegacy) -> Ordering
fn cmp(&self, other: &GameModsLegacy) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for GameModsLegacy
impl PartialEq for GameModsLegacy
Source§impl PartialOrd for GameModsLegacy
impl PartialOrd for GameModsLegacy
Source§impl<S: Fallible + ?Sized> Serialize<S> for GameModsLegacy
Available on crate feature rkyv only.
impl<S: Fallible + ?Sized> Serialize<S> for GameModsLegacy
rkyv only.Source§impl Serialize for GameModsLegacy
Available on crate feature serde only.
impl Serialize for GameModsLegacy
serde only.Source§impl Sub for GameModsLegacy
impl Sub for GameModsLegacy
Source§fn sub(self, other: Self) -> Self
fn sub(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
Source§type Output = GameModsLegacy
type Output = GameModsLegacy
- operator.Source§impl SubAssign for GameModsLegacy
impl SubAssign for GameModsLegacy
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
Source§impl TryFrom<Acronym> for GameModsLegacy
impl TryFrom<Acronym> for GameModsLegacy
impl Copy for GameModsLegacy
impl Eq for GameModsLegacy
impl StructuralPartialEq for GameModsLegacy
Auto Trait Implementations§
impl Freeze for GameModsLegacy
impl RefUnwindSafe for GameModsLegacy
impl Send for GameModsLegacy
impl Sync for GameModsLegacy
impl Unpin for GameModsLegacy
impl UnsafeUnpin for GameModsLegacy
impl UnwindSafe for GameModsLegacy
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.