Struct Array

Source
pub struct Array<T: ToValue + FromValue>(/* private fields */);
Expand description

Array<A> wraps an OCaml 'a array without converting it to Rust

Implementations§

Source§

impl Array<Float>

Source

pub fn set_double(&mut self, i: usize, f: f64) -> Result<(), Error>

Set value to double array

Source

pub unsafe fn set_f64_unchecked(&mut self, i: usize, f: f64)

Set value to double array without bounds checking

§Safety

This function performs no bounds checking

Source

pub fn get_f64(&self, i: usize) -> Result<f64, Error>

Get a value from a double array

Source

pub unsafe fn get_double_unchecked(&self, i: usize) -> f64

Get a value from a double array without checking if the array is actually a double array

§Safety

This function does not perform bounds checking

Source§

impl<T: ToValue + FromValue> Array<T>

Source

pub unsafe fn alloc(n: usize) -> Array<T>

Allocate a new Array

Source

pub fn is_f64(&self) -> bool

Check if Array contains only doubles, if so get_f64 and set_f64 should be used to access values

Source

pub fn len(&self) -> usize

Array length

Source

pub fn is_empty(&self) -> bool

Returns true when the array is empty

Source

pub unsafe fn set(&mut self, rt: &Runtime, i: usize, v: &T) -> Result<(), Error>

Set array index

Source

pub unsafe fn set_unchecked(&mut self, rt: &Runtime, i: usize, v: &T)

Set array index without bounds checking

§Safety

This function does not perform bounds checking

Source

pub unsafe fn get(&self, rt: &Runtime, i: usize) -> Result<T, Error>

Get array index

Source

pub unsafe fn get_unchecked(&self, i: usize) -> T

Get array index without bounds checking

§Safety

This function does not perform bounds checking

Source

pub fn into_vec(self) -> Vec<T>

Array as Vec

Source

pub unsafe fn as_vec(&self, rt: &Runtime) -> Result<Vec<T>, Error>

Array as Vec

Trait Implementations§

Source§

impl<T: Clone + ToValue + FromValue> Clone for Array<T>

Source§

fn clone(&self) -> Array<T>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: ToValue + FromValue> FromValue for Array<T>

Source§

fn from_value(value: Value) -> Self

Convert from OCaml value
Source§

impl<T: PartialEq + ToValue + FromValue> PartialEq for Array<T>

Source§

fn eq(&self, other: &Array<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: ToValue + FromValue> ToValue for Array<T>

Source§

fn to_value(&self, _rt: &Runtime) -> Value

Convert to OCaml value
Source§

impl<T: Eq + ToValue + FromValue> Eq for Array<T>

Source§

impl<T: ToValue + FromValue> StructuralPartialEq for Array<T>

Auto Trait Implementations§

§

impl<T> Freeze for Array<T>

§

impl<T> !RefUnwindSafe for Array<T>

§

impl<T> !Send for Array<T>

§

impl<T> !Sync for Array<T>

§

impl<T> Unpin for Array<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Array<T>

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<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.