Trait std::ops::SliceMutExperimental
[-]
[+]
[src]
pub trait SliceMut<Idx, Result> { fn as_mut_slice_(&'a mut self) -> &'a mut Result; fn slice_from_or_fail_mut(&'a mut self, from: &Idx) -> &'a mut Result; fn slice_to_or_fail_mut(&'a mut self, to: &Idx) -> &'a mut Result; fn slice_or_fail_mut(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result; }
The SliceMut
trait is used to specify the functionality of slicing
operations like arr[from..to]
, when used in a mutable context.
Example
A trivial implementation of SliceMut
. When Foo[Foo..]
happens, it ends up
calling slice_from_mut
, and therefore, main
prints Slicing!
.
#[deriving(Copy)] struct Foo; impl SliceMut<Foo, Foo> for Foo { fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Foo { println!("Slicing!"); self } fn slice_from_or_fail_mut<'a>(&'a mut self, _from: &Foo) -> &'a mut Foo { println!("Slicing!"); self } fn slice_to_or_fail_mut<'a>(&'a mut self, _to: &Foo) -> &'a mut Foo { println!("Slicing!"); self } fn slice_or_fail_mut<'a>(&'a mut self, _from: &Foo, _to: &Foo) -> &'a mut Foo { println!("Slicing!"); self } } pub fn main() { Foo[mut Foo..]; }
Required Methods
fn as_mut_slice_(&'a mut self) -> &'a mut Result
The method for the slicing operation foo[]
fn slice_from_or_fail_mut(&'a mut self, from: &Idx) -> &'a mut Result
The method for the slicing operation foo[from..]
fn slice_to_or_fail_mut(&'a mut self, to: &Idx) -> &'a mut Result
The method for the slicing operation foo[..to]
fn slice_or_fail_mut(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result
The method for the slicing operation foo[from..to]