Bundle

Struct Bundle 

Source
pub struct Bundle<Content: ResourceType, const AMOUNT: u32> { /* private fields */ }
Expand description

Contains a fixed (compile-time known) amount of a resource. A Bundle can be used to build structures or as input for recipes.

Implementations§

Source§

impl<Content: ResourceType, const AMOUNT: u32> Bundle<Content, AMOUNT>

Source

pub const AMOUNT: u32 = AMOUNT

The fixed amount of resource contained in this Bundle.

Source

pub const fn amount(&self) -> u32

Returns the fixed amount of resource contained in this Bundle.

Source

pub const fn split<const AMOUNT1: u32, const AMOUNT2: u32>( self, ) -> (Bundle<Content, AMOUNT1>, Bundle<Content, AMOUNT2>)
where Assert<{ _ }>: IsTrue,

Splits this Bundle into two smaller Bundles with the specified amounts. The sum of AMOUNT1 and AMOUNT2 must equal the amount of this Bundle.

Source

pub const fn to_resource(self) -> Resource<Content>

Converts this Bundle into a Resource with the same resource type and amount.

Trait Implementations§

Source§

impl<Content: ResourceType, const AMOUNT: u32> Add<Bundle<Content, AMOUNT>> for Resource<Content>

Source§

type Output = Resource<Content>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Bundle<Content, AMOUNT>) -> Self::Output

Performs the + operation. Read more
Source§

impl<Content: ResourceType, const AMOUNT_LHS: u32, const AMOUNT_RHS: u32> Add<Bundle<Content, AMOUNT_RHS>> for Bundle<Content, AMOUNT_LHS>
where [(); { _ }]:,

Source§

type Output = Bundle<Content, { AMOUNT_LHS + AMOUNT_RHS }>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Bundle<Content, AMOUNT_RHS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<Content: ResourceType, const AMOUNT: u32> Add<Resource<Content>> for Bundle<Content, AMOUNT>

Source§

type Output = Resource<Content>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Resource<Content>) -> Self::Output

Performs the + operation. Read more
Source§

impl<Content: ResourceType, const AMOUNT: u32> AddAssign<Bundle<Content, AMOUNT>> for Resource<Content>

Source§

fn add_assign(&mut self, bundle: Bundle<Content, AMOUNT>)

Performs the += operation. Read more
Source§

impl<Content: Debug + ResourceType, const AMOUNT: u32> Debug for Bundle<Content, AMOUNT>

Source§

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

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

impl<Content: ResourceType, const AMOUNT: u32> From<Bundle<Content, AMOUNT>> for Resource<Content>

Source§

fn from(bundle: Bundle<Content, AMOUNT>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<Content, const AMOUNT: u32> Freeze for Bundle<Content, AMOUNT>

§

impl<Content, const AMOUNT: u32> RefUnwindSafe for Bundle<Content, AMOUNT>
where Content: RefUnwindSafe,

§

impl<Content, const AMOUNT: u32> Send for Bundle<Content, AMOUNT>
where Content: Send,

§

impl<Content, const AMOUNT: u32> Sync for Bundle<Content, AMOUNT>
where Content: Sync,

§

impl<Content, const AMOUNT: u32> Unpin for Bundle<Content, AMOUNT>
where Content: Unpin,

§

impl<Content, const AMOUNT: u32> UnwindSafe for Bundle<Content, AMOUNT>
where Content: UnwindSafe,

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> 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> 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, 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.