Skip to main content

DefaultSlot

Struct DefaultSlot 

Source
pub struct DefaultSlot<'a, I: Item, II: ItemInstance<I>> {
    pub item_instance: Option<II>,
    pub modified: bool,
    pub phantom: PhantomData<&'a I>,
}
Expand description

A sample slot struct used for testing.

A significant reduction in boiler plate would come from making your own slot non-generic. For the purpose of an example, I decided that I wanted mine to be generic to prove it was possible if for some reason you need that functionality.

The main thing you probably want to change other than that is the transfer method. some methods like half_stack_split and combine_stack would be pretty useful.

Fields§

§item_instance: Option<II>§modified: bool§phantom: PhantomData<&'a I>

Trait Implementations§

Source§

impl<'a, I: Item, II: ItemInstance<I> + Debug> Debug for DefaultSlot<'a, I, II>

Source§

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

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

impl<'a, I: Item, II: ItemInstance<I> + Sized + Clone> Slot<I, II> for DefaultSlot<'a, I, II>

Source§

fn item_instance(&self) -> Option<II>

Get the item instance stored by this slot.
Source§

fn set_item_instance(&mut self, item_instance: &Option<II>)

Set the item instance stored by this slot.
Source§

fn modified(&mut self) -> bool

Whether the slots contents have been modified.
Source§

fn set_modified(&mut self, modified: bool)

Sets whether the slots contents have been modified.
Source§

fn new(item_instance: Option<II>) -> Self

Source§

fn transfer(&mut self, item_instance: Option<II>, _button: &str) -> Option<II>

Switch out the item instance stored in this slot with some rules. Read more

Auto Trait Implementations§

§

impl<'a, I, II> Freeze for DefaultSlot<'a, I, II>
where II: Freeze,

§

impl<'a, I, II> RefUnwindSafe for DefaultSlot<'a, I, II>

§

impl<'a, I, II> Send for DefaultSlot<'a, I, II>
where II: Send, I: Sync,

§

impl<'a, I, II> Sync for DefaultSlot<'a, I, II>
where II: Sync, I: Sync,

§

impl<'a, I, II> Unpin for DefaultSlot<'a, I, II>
where II: Unpin,

§

impl<'a, I, II> UnsafeUnpin for DefaultSlot<'a, I, II>
where II: UnsafeUnpin,

§

impl<'a, I, II> UnwindSafe for DefaultSlot<'a, I, II>
where II: UnwindSafe, I: RefUnwindSafe,

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.