Struct wrapped_mono::Array
source · pub struct Array<Dim: DimensionTrait, T: InteropSend + InteropRecive + InteropClass>where
Dim::Lengths: IndexMut<usize> + BorrowMut<[usize]> + Copy,
<Dim::Lengths as Index<usize>>::Output: BorrowMut<usize>,
<<Dim as DimensionTrait>::Lengths as Index<usize>>::Output: Sized + Into<usize> + Copy,{ /* private fields */ }
Expand description
Safe, rust representation of MonoArray
(a reference to a managed array).
Nullable support
Array<T>
is non-nullable on default and will panic when null passed as argument form managed code. For nullable support use Option<Array<T>>
.
Implementations§
source§impl<T: InteropSend + InteropRecive + InteropClass, Dim: DimensionTrait> Array<Dim, T>where
Dim::Lengths: IndexMut<usize> + BorrowMut<[usize]> + Copy,
<Dim::Lengths as Index<usize>>::Output: BorrowMut<usize>,
<<Dim as DimensionTrait>::Lengths as Index<usize>>::Output: Sized + Into<usize> + Copy,
<Dim as DimensionTrait>::Lengths: BorrowMut<[usize]>,
impl<T: InteropSend + InteropRecive + InteropClass, Dim: DimensionTrait> Array<Dim, T>where Dim::Lengths: IndexMut<usize> + BorrowMut<[usize]> + Copy, <Dim::Lengths as Index<usize>>::Output: BorrowMut<usize>, <<Dim as DimensionTrait>::Lengths as Index<usize>>::Output: Sized + Into<usize> + Copy, <Dim as DimensionTrait>::Lengths: BorrowMut<[usize]>,
sourcepub fn get(&self, indices: Dim::Lengths) -> T
pub fn get(&self, indices: Dim::Lengths) -> T
Function returning element at index
Arguments
Name | Type | Description |
---|---|---|
self | &Self | Array to read from. |
indices | [usize;DIMENSIONS as usize] | An n-dimensional array containing indices to read value at |
Examples
fn some_get_fn(input:&Array<Dim1D,f32>)->f32{
let a = input.get([0]);
let b = input.get([1]);
a + b
}
fn some_get_fn_2D(input:&Array<Dim2D,f32>)->f32{
let a = input.get([0,0]);
let b = input.get([1,1]);
let c = input.get([0,1]);
a + b + c
}
sourcepub fn set(&mut self, indices: Dim::Lengths, value: T)
pub fn set(&mut self, indices: Dim::Lengths, value: T)
Function setting element at index of Array
to value
Arguments
Name | Type | Description |
---|---|---|
self | &Self | Array to write value to. |
indices | [usize;DIMENSIONS as usize] | An n-dimensional array containing indices to set value at |
value | T | value to set element at index to. |
Example
fn set_fn(input:&mut Array<Dim1D,i32>){
input.set([0],0);
input.set([1],1);
}
fn set_fn_2D(input:&mut Array<Dim2D,i32>){
input.set([0,0],0);
input.set([1,1],1);
input.set([1,0],9);
}
sourcepub fn new(domain: &Domain, size: &Dim::Lengths) -> Self
pub fn new(domain: &Domain, size: &Dim::Lengths) -> Self
Allocate new array in domain with size DIMENSIONS with elements of type class.
Example
let arr_len = 8;
let arr = Array::<Dim1D,i32>::new(&domain,&[arr_len]);
assert!(arr.len() == arr_len);
Arguments
Name | Type | Description |
---|---|---|
domain | &Domain | domain to create array in |
size | &[usize;DIMENSIONS as usize] | size of the array to create |
sourcepub fn clone_managed_array(&self) -> Self
pub fn clone_managed_array(&self) -> Self
Clones managed array, not the reference to it.
Arguments
Name | Type | Description |
---|---|---|
self | &Array | Array to clone |
sourcepub fn get_lenghts(&self) -> Dim::Lengths
pub fn get_lenghts(&self) -> Dim::Lengths
Returns n-dimensional length of this array.
Arguments
Name | Type | Description |
---|---|---|
self | &Array | Array to get size of |
Trait Implementations§
source§impl<Dim: DimensionTrait, T: InteropSend + InteropRecive + InteropClass> Clone for Array<Dim, T>where
Dim::Lengths: IndexMut<usize> + BorrowMut<[usize]> + Copy,
<Dim::Lengths as Index<usize>>::Output: BorrowMut<usize>,
<<Dim as DimensionTrait>::Lengths as Index<usize>>::Output: Sized + Into<usize> + Copy,
impl<Dim: DimensionTrait, T: InteropSend + InteropRecive + InteropClass> Clone for Array<Dim, T>where Dim::Lengths: IndexMut<usize> + BorrowMut<[usize]> + Copy, <Dim::Lengths as Index<usize>>::Output: BorrowMut<usize>, <<Dim as DimensionTrait>::Lengths as Index<usize>>::Output: Sized + Into<usize> + Copy,
source§impl<T: InteropSend + InteropRecive + InteropClass + Clone> From<&[T]> for Array<Dim1D, T>
impl<T: InteropSend + InteropRecive + InteropClass + Clone> From<&[T]> for Array<Dim1D, T>
source§impl<Dim: DimensionTrait, T: InteropSend + InteropRecive + InteropClass> InteropClass for Array<Dim, T>where
Dim::Lengths: IndexMut<usize> + BorrowMut<[usize]> + Copy,
<Dim::Lengths as Index<usize>>::Output: BorrowMut<usize>,
<<Dim as DimensionTrait>::Lengths as Index<usize>>::Output: Sized + Into<usize> + Copy,
impl<Dim: DimensionTrait, T: InteropSend + InteropRecive + InteropClass> InteropClass for Array<Dim, T>where Dim::Lengths: IndexMut<usize> + BorrowMut<[usize]> + Copy, <Dim::Lengths as Index<usize>>::Output: BorrowMut<usize>, <<Dim as DimensionTrait>::Lengths as Index<usize>>::Output: Sized + Into<usize> + Copy,
fn get_mono_class() -> Class
source§impl<Dim: DimensionTrait, T: InteropSend + InteropRecive + InteropClass> ObjectTrait for Array<Dim, T>where
Dim::Lengths: IndexMut<usize> + BorrowMut<[usize]> + Copy,
<Dim::Lengths as Index<usize>>::Output: BorrowMut<usize>,
<<Dim as DimensionTrait>::Lengths as Index<usize>>::Output: Sized + Into<usize> + Copy,
impl<Dim: DimensionTrait, T: InteropSend + InteropRecive + InteropClass> ObjectTrait for Array<Dim, T>where Dim::Lengths: IndexMut<usize> + BorrowMut<[usize]> + Copy, <Dim::Lengths as Index<usize>>::Output: BorrowMut<usize>, <<Dim as DimensionTrait>::Lengths as Index<usize>>::Output: Sized + Into<usize> + Copy,
source§unsafe fn from_ptr_unchecked(ptr: *mut MonoObject) -> Self
unsafe fn from_ptr_unchecked(ptr: *mut MonoObject) -> Self
fn cast<Target: ObjectTrait>(&self) -> Option<Target>
source§fn hash(&self) -> i32
fn hash(&self) -> i32
get hash of this object: This hash is not based on values of objects fields, and differs from result of calling object.GetHash() Read more
source§fn get_size(&self) -> u32
fn get_size(&self) -> u32
get size of managed object referenced by self in bytes. Does include builtin hidden data. Read more
source§impl<Dim: DimensionTrait, T: InteropSend + InteropRecive + InteropClass, O: ObjectTrait> PartialEq<O> for Array<Dim, T>where
Dim::Lengths: IndexMut<usize> + BorrowMut<[usize]> + Copy,
<Dim::Lengths as Index<usize>>::Output: BorrowMut<usize>,
<<Dim as DimensionTrait>::Lengths as Index<usize>>::Output: Sized + Into<usize> + Copy,
impl<Dim: DimensionTrait, T: InteropSend + InteropRecive + InteropClass, O: ObjectTrait> PartialEq<O> for Array<Dim, T>where Dim::Lengths: IndexMut<usize> + BorrowMut<[usize]> + Copy, <Dim::Lengths as Index<usize>>::Output: BorrowMut<usize>, <<Dim as DimensionTrait>::Lengths as Index<usize>>::Output: Sized + Into<usize> + Copy,
Auto Trait Implementations§
impl<Dim, T> RefUnwindSafe for Array<Dim, T>where T: RefUnwindSafe, <Dim as DimensionTrait>::Lengths: RefUnwindSafe,
impl<Dim, T> Send for Array<Dim, T>where T: Send, <Dim as DimensionTrait>::Lengths: Send,
impl<Dim, T> Sync for Array<Dim, T>where T: Sync, <Dim as DimensionTrait>::Lengths: Sync,
impl<Dim, T> Unpin for Array<Dim, T>where T: Unpin, <Dim as DimensionTrait>::Lengths: Unpin,
impl<Dim, T> UnwindSafe for Array<Dim, T>where T: UnwindSafe, <Dim as DimensionTrait>::Lengths: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> InteropRecive for Twhere
T: ObjectTrait,
impl<T> InteropRecive for Twhere T: ObjectTrait,
§type SourceType = *mut _MonoObject
type SourceType = *mut _MonoObject
Souce type used by
MonoRuntime
when calling functions exposed by add_internal_call
, or getting a value back from a method, that can be converted to a rust type.source§fn get_rust_rep(src: <T as InteropRecive>::SourceType) -> T
fn get_rust_rep(src: <T as InteropRecive>::SourceType) -> T
Function converting
Self::SourceType
to type implementing InteropRecive
trait.source§impl<T> InteropSend for Twhere
T: ObjectTrait,
impl<T> InteropSend for Twhere T: ObjectTrait,
§type TargetType = *mut _MonoObject
type TargetType = *mut _MonoObject
Type used by
MonoRuntime
, that type implementing InteropSend
trait should be converted to when returning it to MonoRuntime
.source§fn get_mono_rep(src: T) -> <T as InteropSend>::TargetType
fn get_mono_rep(src: T) -> <T as InteropSend>::TargetType
Function converting type implementing
InteropRecive
trait to type that should be returned to MonoRuntime
.