GameModsIntermode

Struct GameModsIntermode 

Source
pub struct GameModsIntermode { /* private fields */ }
Expand description

Combination of GameModIntermodes.

Implementations§

Source§

impl GameModsIntermode

Source

pub const fn new() -> Self

Returns empty mods i.e. “NoMod

Source

pub fn bits(&self) -> u32

Return the accumulated bit values of all contained mods.

Mods that don’t have bit values will be ignored. See https://github.com/ppy/osu-api/wiki#mods

§Example
use rosu_mods::mods;

let hdhrdtwu = mods!(HD HR DT WU);
assert_eq!(hdhrdtwu.bits(), 8 + 16 + 64);
Source

pub fn checked_bits(&self) -> Option<u32>

Return the accumulated bit values of all contained mods.

If any contained mod has no bit value None is returned. See https://github.com/ppy/osu-api/wiki#mods

§Example
use rosu_mods::mods;

let hdhrdt = mods!(HD HR DT);
assert_eq!(hdhrdt.checked_bits(), Some(8 + 16 + 64));

let hdhrdtwu = mods!(HD HR DT WU);
assert_eq!(hdhrdtwu.checked_bits(), None);
Source

pub fn is_empty(&self) -> bool

Returns true if no mods are contained.

§Example
use rosu_mods::{GameModIntermode, GameModsIntermode};

let mut mods = GameModsIntermode::new();
assert!(mods.is_empty());

mods.insert(GameModIntermode::Hidden);
assert!(!mods.is_empty());
Source

pub fn len(&self) -> usize

Returns the amount of contained mods.

§Example
use rosu_mods::{mods, GameModIntermode, GameModsIntermode};

let hdhrdt = mods!(HD HR DT);
assert_eq!(hdhrdt.len(), 3);

let mut nm = GameModsIntermode::new();
assert_eq!(nm.len(), 0);
assert_eq!(nm.to_string(), "NM");
Source

pub fn insert(&mut self, gamemod: GameModIntermode)

Add a GameModIntermode

§Example
use rosu_mods::{GameModIntermode, GameModsIntermode};

let mut mods = GameModsIntermode::new();
assert_eq!(mods.to_string(), "NM");

mods.insert(GameModIntermode::Traceable);
assert_eq!(mods.to_string(), "TC");

mods.insert(GameModIntermode::HardRock);
assert_eq!(mods.to_string(), "HRTC");
Source

pub fn contains<M>(&self, gamemod: M) -> bool

Check whether a given mod is contained.

§Example
use rosu_mods::{mods, GameModIntermode};

let hd = mods!(HD);
assert!(hd.contains(GameModIntermode::Hidden));
assert!(!hd.contains(GameModIntermode::HardRock));
Source

pub fn contains_acronym(&self, acronym: Acronym) -> bool

Check whether a given Acronym is contained.

§Example
use rosu_mods::{mods, Acronym};

let nc = mods!(NC);
assert!(nc.contains_acronym("NC".parse::<Acronym>().unwrap()));
assert!(!nc.contains_acronym("DT".parse::<Acronym>().unwrap()));
Source

pub fn remove<M>(&mut self, gamemod: M) -> bool

Remove a gamemod and return whether it was contained.

§Example
use rosu_mods::{mods, GameModIntermode, GameModsIntermode};

let mut mods: GameModsIntermode = mods!(HD HR);

assert!(mods.remove(GameModIntermode::Hidden));
assert_eq!(mods.to_string(), "HR");
assert!(!mods.remove(GameModIntermode::DoubleTime));
Source

pub fn remove_all<I, M>(&mut self, mods: I)
where I: IntoIterator<Item = M>, GameModIntermode: From<M>,

Remove all mods contained in the iterator.

§Example
use rosu_mods::{mods, GameModIntermode, GameModsIntermode};

let mut mods: GameModsIntermode = mods!(HD HR WG DT BR);

mods.remove_all([GameModIntermode::Hidden, GameModIntermode::Easy]);
assert_eq!(mods.to_string(), "DTHRBRWG");

mods.remove_all(mods!(NF WG));
assert_eq!(mods.to_string(), "DTHRBR")
Source

pub fn from_bits(bits: u32) -> Self

Parse bitflags into GameModsIntermode

§Example
use rosu_mods::{mods, GameModsIntermode};

let bits = 8 + 64 + 512 + 1024;
assert_eq!(GameModsIntermode::from_bits(bits), mods!(FL HD NC))
Source

pub fn try_from_acronyms(s: &str) -> Option<Self>

Try to parse a combination of mod acronyms into GameModsIntermode.

Returns None if an unknown acronym was encountered.

§Example
use rosu_mods::GameModsIntermode;

let hdhrwu = GameModsIntermode::try_from_acronyms("HRWUHD").unwrap();
assert_eq!(hdhrwu.to_string(), "HDHRWU");

assert!(GameModsIntermode::try_from_acronyms("QQQ").is_none());
Source

pub fn from_acronyms(s: &str) -> Self

Parse a combination of mod acronyms into GameModsIntermode.

§Example
use rosu_mods::GameModsIntermode;

let hdhrwu = GameModsIntermode::from_acronyms("HRWUHD");
assert_eq!(hdhrwu.len(), 3);
assert_eq!(hdhrwu.to_string(), "HDHRWU");

let mut iter = GameModsIntermode::from_acronyms("QQhdQ").into_iter();
assert_eq!(iter.next().unwrap().to_string(), "HDQ"); // unknown mod
assert_eq!(iter.next().unwrap().to_string(), "QQ");  // unknown mod
assert!(iter.next().is_none());
Source

pub fn intersection<'m>( &'m self, other: &'m GameModsIntermode, ) -> GameModsIntermodeIntersection<'m>

Returns an iterator over all mods that appear in both GameModsIntermode.

§Example
use rosu_mods::{mods, GameModIntermode};

let hd = mods!(HD);
let hdhr = mods!(HD HR);
let mut intersection = hd.intersection(&hdhr);
assert_eq!(intersection.next(), Some(GameModIntermode::Hidden));
assert_eq!(intersection.next(), None);
Source

pub fn intersects(&self, other: &Self) -> bool

Check whether the two GameMods have any common mods.

§Example
use rosu_mods::mods;

let hd = mods!(HD);
assert!(!hd.intersects(&mods!(HR)));
assert!(hd.intersects(&mods!(HD HR)));
Source

pub fn legacy_clock_rate(&self) -> f64

The legacy clock rate of the GameModsIntermode.

Looks for the first occurrence of DT, NC, HT, or DC and returns 1.5, 0.75, or 1.0 accordingly.

§Example
use rosu_mods::{mods, GameModIntermode};

let hd = mods!(HD);
assert_eq!(hd.legacy_clock_rate(), 1.0);

let mut hddt = hd;
hddt.insert(GameModIntermode::DoubleTime);
assert_eq!(hddt.legacy_clock_rate(), 1.5);
Source

pub fn iter(&self) -> GameModsIntermodeIter<'_>

Returns an iterator over all contained mods.

Note that the iterator will immediately yield None in case of “NoMod”.

Source

pub fn try_with_mode(&self, mode: GameMode) -> Option<GameMods>

Tries to turn a GameModsIntermode into a GameMods.

Returns None if any contained GameModIntermode is unknown for the given GameMode.

§Example
use rosu_mods::{mods, GameMods, GameMode};

let dtfi: GameMods = mods!(DT FI).try_with_mode(GameMode::Mania).unwrap();

// The FadeIn mod doesn't exist in Taiko
assert!(mods!(DT FI).try_with_mode(GameMode::Taiko).is_none());
Source

pub fn with_mode(&self, mode: GameMode) -> GameMods

Turn a GameModsIntermode into a GameMods.

Any contained GameModIntermode that’s unknown for the given GameMode will be replaced with GameModIntermode::Unknown.

§Example
use rosu_mods::{mods, GameMods, GameMode};

let dtfi: GameMods = mods!(DT FI).with_mode(GameMode::Mania);

// The FadeIn mod doesn't exist in Taiko
let dt_unknown: GameMods = mods!(DT FI).with_mode(GameMode::Taiko);
assert_eq!(dt_unknown.to_string(), "DTFI");
Source

pub fn as_legacy(&self) -> GameModsLegacy

Source

pub fn try_as_legacy(&self) -> Option<GameModsLegacy>

Attempts to turns GameModsIntermode into GameModsLegacy.

Returns None if any contained GameModIntermode does not have a bit value.

Trait Implementations§

Source§

impl Archive for GameModsIntermode

Available on crate feature rkyv only.
Source§

type Archived = <Vec<GameModIntermode> as Archive>::Archived

The archived representation of this type. Read more
Source§

type Resolver = VecResolver

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
Source§

fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)

Creates the archived version of this value at the given position and writes it to the given output. Read more
Source§

const COPY_OPTIMIZATION: CopyOptimization<Self> = _

An optimization flag that allows the bytes of this type to be copied directly to a writer instead of calling serialize. Read more
Source§

impl BitOr<GameModIntermode> for GameModsIntermode

Source§

fn bitor(self, rhs: GameModIntermode) -> Self::Output

Source§

type Output = GameModsIntermode

The resulting type after applying the | operator.
Source§

impl BitOrAssign<GameModIntermode> for GameModsIntermode

Source§

impl Clone for GameModsIntermode

Source§

fn clone(&self) -> GameModsIntermode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GameModsIntermode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl Default for GameModsIntermode

Source§

fn default() -> GameModsIntermode

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for GameModsIntermode

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<D: Fallible + ?Sized> Deserialize<GameModsIntermode, D> for ArchivedVec<Archived<GameModIntermode>>

Available on crate feature rkyv only.
Source§

fn deserialize(&self, _: &mut D) -> Result<GameModsIntermode, D::Error>

Deserializes using the given deserializer
Source§

impl Display for GameModsIntermode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl<M> Extend<M> for GameModsIntermode

Source§

fn extend<T: IntoIterator<Item = M>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<GameModIntermode> for GameModsIntermode

Source§

fn from(gamemod: GameModIntermode) -> Self

Converts to this type from the input type.
Source§

impl From<GameMods> for GameModsIntermode

Source§

fn from(mods: GameMods) -> Self

Converts to this type from the input type.
Source§

impl From<GameModsLegacy> for GameModsIntermode

Source§

fn from(mods: GameModsLegacy) -> Self

Converts to this type from the input type.
Source§

impl<M> FromIterator<M> for GameModsIntermode

Source§

fn from_iter<T: IntoIterator<Item = M>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromStr for GameModsIntermode

Source§

type Err = Infallible

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for GameModsIntermode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> IntoIterator for &'a GameModsIntermode

Source§

type Item = <GameModsIntermodeIter<'a> as Iterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = GameModsIntermodeIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for GameModsIntermode

Source§

fn into_iter(self) -> Self::IntoIter

Turns GameModsIntermode into an iterator over all contained mods.

Note that the iterator will immediately yield None in case of “NoMod”.

Source§

type Item = GameModIntermode

The type of the elements being iterated over.
Source§

type IntoIter = IntoGameModsIntermodeIter

Which kind of iterator are we turning this into?
Source§

impl PartialEq for GameModsIntermode

Source§

fn eq(&self, other: &GameModsIntermode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Fallible + Allocator + Writer + ?Sized> Serialize<S> for GameModsIntermode

Available on crate feature rkyv only.
Source§

fn serialize(&self, s: &mut S) -> Result<Self::Resolver, S::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
Source§

impl Serialize for GameModsIntermode

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Sub<GameModIntermode> for GameModsIntermode

Source§

fn sub(self, rhs: GameModIntermode) -> Self::Output

Source§

type Output = GameModsIntermode

The resulting type after applying the - operator.
Source§

impl SubAssign<GameModIntermode> for GameModsIntermode

Source§

impl Eq for GameModsIntermode

Source§

impl StructuralPartialEq for GameModsIntermode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> ArchiveUnsized for T
where T: Archive,

Source§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
Source§

fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata

Creates the archived version of the metadata for this value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T, S> SerializeUnsized<S> for T
where T: Serialize<S>, S: Fallible + Writer + ?Sized,

Source§

fn serialize_unsized( &self, serializer: &mut S, ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,