pub trait CopyOps<T>: TooDeeOpsMut<T> {
// Provided methods
fn copy_from_slice(&mut self, src: &[T])
where T: Copy { ... }
fn clone_from_slice(&mut self, src: &[T])
where T: Clone { ... }
fn copy_from_toodee(&mut self, src: &impl TooDeeOps<T>)
where T: Copy { ... }
fn clone_from_toodee(&mut self, src: &impl TooDeeOps<T>)
where T: Clone { ... }
fn copy_within(&mut self, src: (Coordinate, Coordinate), dest: Coordinate)
where T: Copy { ... }
}
Expand description
Provides basic copying operations for TooDee
structures.
Provided Methods§
sourcefn copy_from_slice(&mut self, src: &[T])where
T: Copy,
fn copy_from_slice(&mut self, src: &[T])where T: Copy,
Copies data from another slice into this area. The source slice’s length must match the size of this object’s area. Data is copied row by row.
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut,CopyOps};
let ascending = vec![0, 1, 2, 3, 4];
let mut toodee : TooDee<u32> = TooDee::new(10, 5);
toodee.view_mut((5, 1), (10, 2)).copy_from_slice(&ascending);
sourcefn clone_from_slice(&mut self, src: &[T])where
T: Clone,
fn clone_from_slice(&mut self, src: &[T])where T: Clone,
Clones data from another slice into this area. The source slice’s length must match the size of this object’s area. Data is cloned row by row.
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut,CopyOps};
let ascending = vec![0, 1, 2, 3, 4];
let mut toodee : TooDee<u32> = TooDee::new(10, 5);
toodee.view_mut((5, 1), (10, 2)).clone_from_slice(&ascending);
sourcefn copy_from_toodee(&mut self, src: &impl TooDeeOps<T>)where
T: Copy,
fn copy_from_toodee(&mut self, src: &impl TooDeeOps<T>)where T: Copy,
Copies data from another TooDeeOps
object into this one. The source and
destination dimensions must match.
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut,CopyOps};
let ascending = TooDee::from_vec(5, 1, vec![0, 1, 2, 3, 4]);
let mut toodee : TooDee<u32> = TooDee::new(10, 5);
toodee.view_mut((5, 1), (10, 2)).copy_from_toodee(&ascending);
sourcefn clone_from_toodee(&mut self, src: &impl TooDeeOps<T>)where
T: Clone,
fn clone_from_toodee(&mut self, src: &impl TooDeeOps<T>)where T: Clone,
Copies data from another TooDeeOps
object into this one. The source and
destination dimensions must match.
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut,CopyOps};
let ascending = TooDee::from_vec(5, 1, vec![0, 1, 2, 3, 4]);
let mut toodee : TooDee<u32> = TooDee::new(10, 5);
toodee.view_mut((5, 1), (10, 2)).clone_from_toodee(&ascending);
sourcefn copy_within(&mut self, src: (Coordinate, Coordinate), dest: Coordinate)where
T: Copy,
fn copy_within(&mut self, src: (Coordinate, Coordinate), dest: Coordinate)where T: Copy,
Copies the src
area (top-left to bottom-right) to a destination area. dest
specifies
the top-left position of destination area. The src
area will be partially overwritten
if the regions overlap.
Panics
Panics if:
src
dimensions are outside the array’s bounds- there’s insufficient room to copy all of
src
todest
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut,CopyOps};
let mut toodee : TooDee<u32> = TooDee::new(10, 5);
toodee.view_mut((0, 0), (5, 1)).fill(42);
assert_eq!(toodee[(3,1)], 0);
toodee.copy_within(((0, 0), (5, 1)), (0, 1));
assert_eq!(toodee[(3,1)], 42);