Skip to main content

MultiSimulation

Struct MultiSimulation 

Source
pub struct MultiSimulation<Info: SimulationInfo> { /* private fields */ }
Expand description

A simulation with support for multiple states.

Implementations§

Source§

impl<Info: SimulationInfo> MultiSimulation<Info>

Source

pub fn new<T: Into<Info>>(info: T) -> Self

Creates a new MultiSimulation from the provided info with no states.

Source

pub fn add_simulation(&mut self) -> usize

Adds a new simulation state to the simulation and returns its index.

Source

pub fn add_simulation_from_data( &mut self, data: Info::LoadData, ) -> Result<usize, Info::StateLoadingError>

Adds a new simulation state loaded from the provided data to the simulation and returns its index.

§Errors

Returns an error if a valid state cannot be loaded from data.

Source

pub fn remove_simulation(&mut self, index: usize) -> Option<Info::State>

Removes the simulation state at the specified index and returns it.

All states after index shift down by one position, so their indices decrease by one. Returns None if index is out of bounds, leaving the simulation unchanged.

Source

pub fn get(&self, index: usize) -> Option<SimulationBorrowRef<'_, Info>>

Retrieves an immutable borrow of the simulation at the specified index.

Source

pub fn get_mut(&mut self, index: usize) -> Option<SimulationBorrowMut<'_, Info>>

Retrieves a mutable borrow of the simulation at the specified index.

Source

pub fn states(&self) -> &[Info::State]

Get access to all simulation states.

Source

pub fn states_mut(&mut self) -> &mut [Info::State]

Get mutable access to all simulation states.

Source

pub fn iter(&self) -> Iter<'_, Info>

Returns an iterator over the simulation states.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, Info>

Returns a mutable iterator over the simulation states.

Source

pub fn release(self) -> Info

Release the info from the simulation again and destroys all states.

Trait Implementations§

Source§

impl<Info: SimulationInfo + Clone> Clone for MultiSimulation<Info>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Info: SimulationInfo> Deref for MultiSimulation<Info>

Source§

type Target = Info

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Info

Dereferences the value.
Source§

impl<Info: EditableSimulationInfo> Editable for MultiSimulation<Info>

Source§

type Edit<'a> = MultiSimulationEdit<'a, Info> where Self: 'a

The type used for safe edits and refreshing the state.
Source§

fn edit(&mut self) -> MultiSimulationEdit<'_, Info>

Creates a type which allows safe edits to the info without invalidating the states, and automatically refreshes the states when the edit type goes out of scope.
Source§

impl<'a, Info: SimulationInfo> IntoIterator for &'a MultiSimulation<Info>

Source§

type Item = SimulationBorrow<'a, Info, &'a <Info as SimulationInfo>::State>

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Info>

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<'a, Info: SimulationInfo> IntoIterator for &'a mut MultiSimulation<Info>

Source§

type Item = SimulationBorrow<'a, Info, &'a mut <Info as SimulationInfo>::State>

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, Info>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<Info> Freeze for MultiSimulation<Info>
where Info: Freeze,

§

impl<Info> RefUnwindSafe for MultiSimulation<Info>

§

impl<Info> Send for MultiSimulation<Info>
where Info: Send, <Info as SimulationInfo>::State: Send,

§

impl<Info> Sync for MultiSimulation<Info>
where Info: Sync, <Info as SimulationInfo>::State: Sync,

§

impl<Info> Unpin for MultiSimulation<Info>
where Info: Unpin, <Info as SimulationInfo>::State: Unpin,

§

impl<Info> UnsafeUnpin for MultiSimulation<Info>
where Info: UnsafeUnpin,

§

impl<Info> UnwindSafe for MultiSimulation<Info>
where Info: UnwindSafe, <Info as SimulationInfo>::State: 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> 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<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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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, 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.