Struct extendr_api::robj::Robj
source · pub struct Robj { /* private fields */ }
Expand description
Wrapper for an R S-expression pointer (SEXP).
Create R objects from rust types and iterators:
use extendr_api::prelude::*;
test! {
// Different ways of making integer scalar 1.
let non_na : Option<i32> = Some(1);
let a : Robj = vec![1].into();
let b = r!(1);
let c = r!(vec![1]);
let d = r!(non_na);
let e = r!([1]);
assert_eq!(a, b);
assert_eq!(a, c);
assert_eq!(a, d);
assert_eq!(a, e);
// Different ways of making boolean scalar TRUE.
let a : Robj = true.into();
let b = r!(TRUE);
assert_eq!(a, b);
// Create a named list
let a = list!(a = 1, b = "x");
assert_eq!(a.len(), 2);
// Use an iterator (like 1:10)
let a = r!(1 ..= 10);
assert_eq!(a, r!([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
// Use an iterator (like (1:10)[(1:10) %% 3 == 0])
let a = (1 ..= 10).filter(|v| v % 3 == 0).collect_robj();
assert_eq!(a, r!([3, 6, 9]));
}
Convert to/from Rust vectors.
use extendr_api::prelude::*;
test! {
let a : Robj = r!(vec![1., 2., 3., 4.]);
let b : Vec<f64> = a.as_real_vector().unwrap();
assert_eq!(a.len(), 4);
assert_eq!(b, vec![1., 2., 3., 4.]);
}
Iterate over names and values.
use extendr_api::prelude::*;
test! {
let abc = list!(a = 1, b = "x", c = vec![1, 2]);
let names : Vec<_> = abc.names().unwrap().collect();
let names_and_values : Vec<_> = abc.as_list().unwrap().iter().collect();
assert_eq!(names, vec!["a", "b", "c"]);
assert_eq!(names_and_values, vec![("a", r!(1)), ("b", r!("x")), ("c", r!(vec![1, 2]))]);
}
NOTE: as much as possible we wish to make this object safe (ie. no segfaults).
If you avoid using unsafe functions it is more likely that you will avoid panics and segfaults. We will take great trouble to ensure that this is true.
Implementations§
source§impl Robj
impl Robj
sourcepub fn is_na(&self) -> bool
pub fn is_na(&self) -> bool
Is this object is an NA scalar? Works for character, integer and numeric types.
use extendr_api::prelude::*;
test! {
assert_eq!(r!(NA_INTEGER).is_na(), true);
assert_eq!(r!(NA_REAL).is_na(), true);
assert_eq!(r!(NA_STRING).is_na(), true);
}
sourcepub fn as_integer_slice<'a>(&self) -> Option<&'a [i32]>
pub fn as_integer_slice<'a>(&self) -> Option<&'a [i32]>
Get a read-only reference to the content of an integer vector.
use extendr_api::prelude::*;
test! {
let robj = r!([1, 2, 3]);
assert_eq!(robj.as_integer_slice().unwrap(), [1, 2, 3]);
}
sourcepub fn as_integer_vector(&self) -> Option<Vec<i32>>
pub fn as_integer_vector(&self) -> Option<Vec<i32>>
Get a Vec
use extendr_api::prelude::*;
test! {
let robj = r!([1, 2, 3]);
assert_eq!(robj.as_integer_slice().unwrap(), vec![1, 2, 3]);
}
sourcepub fn as_logical_slice(&self) -> Option<&[Rbool]>
pub fn as_logical_slice(&self) -> Option<&[Rbool]>
Get a read-only reference to the content of a logical vector using the tri-state Rbool. Returns None if not a logical vector.
use extendr_api::prelude::*;
test! {
let robj = r!([TRUE, FALSE]);
assert_eq!(robj.as_logical_slice().unwrap(), [TRUE, FALSE]);
}
sourcepub fn as_logical_vector(&self) -> Option<Vec<Rbool>>
pub fn as_logical_vector(&self) -> Option<Vec<Rbool>>
Get a Vec
use extendr_api::prelude::*;
test! {
let robj = r!([TRUE, FALSE]);
assert_eq!(robj.as_logical_vector().unwrap(), vec![TRUE, FALSE]);
}
sourcepub fn as_logical_iter(&self) -> Option<impl Iterator<Item = &Rbool>>
pub fn as_logical_iter(&self) -> Option<impl Iterator<Item = &Rbool>>
Get an iterator over logical elements of this slice.
use extendr_api::prelude::*;
test! {
let robj = r!([TRUE, FALSE, NA_LOGICAL]);
let mut num_na = 0;
for val in robj.as_logical_iter().unwrap() {
if val.is_na() {
num_na += 1;
}
}
assert_eq!(num_na, 1);
}
sourcepub fn as_real_slice(&self) -> Option<&[f64]>
pub fn as_real_slice(&self) -> Option<&[f64]>
Get a read-only reference to the content of a double vector. Note: the slice may contain NaN or NA values. We may introduce a “Real” type to handle this like the Rbool type.
use extendr_api::prelude::*;
test! {
let robj = r!([Some(1.), None, Some(3.)]);
let mut tot = 0.;
for val in robj.as_real_slice().unwrap() {
if !val.is_na() {
tot += val;
}
}
assert_eq!(tot, 4.);
}
sourcepub fn as_real_iter(&self) -> Option<impl Iterator<Item = &f64>>
pub fn as_real_iter(&self) -> Option<impl Iterator<Item = &f64>>
Get an iterator over real elements of this slice.
use extendr_api::prelude::*;
test! {
let robj = r!([1., 2., 3.]);
let mut tot = 0.;
for val in robj.as_real_iter().unwrap() {
if !val.is_na() {
tot += val;
}
}
assert_eq!(tot, 6.);
}
sourcepub fn as_real_vector(&self) -> Option<Vec<f64>>
pub fn as_real_vector(&self) -> Option<Vec<f64>>
Get a Vec
use extendr_api::prelude::*;
test! {
let robj = r!([1., 2., 3.]);
assert_eq!(robj.as_real_vector().unwrap(), vec![1., 2., 3.]);
}
sourcepub fn as_raw_slice(&self) -> Option<&[u8]>
pub fn as_raw_slice(&self) -> Option<&[u8]>
Get a read-only reference to the content of an integer or logical vector.
use extendr_api::prelude::*;
test! {
let robj = r!(Raw::from_bytes(&[1, 2, 3]));
assert_eq!(robj.as_raw_slice().unwrap(), &[1, 2, 3]);
}
sourcepub fn as_integer_slice_mut(&mut self) -> Option<&mut [i32]>
pub fn as_integer_slice_mut(&mut self) -> Option<&mut [i32]>
Get a read-write reference to the content of an integer or logical vector.
Note that rust slices are 0-based so slice[1]
is the middle value.
use extendr_api::prelude::*;
test! {
let mut robj = r!([1, 2, 3]);
let slice : & mut [i32] = robj.as_integer_slice_mut().unwrap();
slice[1] = 100;
assert_eq!(robj, r!([1, 100, 3]));
}
sourcepub fn as_real_slice_mut(&mut self) -> Option<&mut [f64]>
pub fn as_real_slice_mut(&mut self) -> Option<&mut [f64]>
Get a read-write reference to the content of a double vector.
Note that rust slices are 0-based so slice[1]
is the middle value.
use extendr_api::prelude::*;
test! {
let mut robj = r!([1.0, 2.0, 3.0]);
let slice = robj.as_real_slice_mut().unwrap();
slice[1] = 100.0;
assert_eq!(robj, r!([1.0, 100.0, 3.0]));
}
sourcepub fn as_raw_slice_mut(&mut self) -> Option<&mut [u8]>
pub fn as_raw_slice_mut(&mut self) -> Option<&mut [u8]>
Get a read-write reference to the content of a raw vector.
use extendr_api::prelude::*;
test! {
let mut robj = r!(Raw::from_bytes(&[1, 2, 3]));
let slice = robj.as_raw_slice_mut().unwrap();
slice[1] = 100;
assert_eq!(robj, r!(Raw::from_bytes(&[1, 100, 3])));
}
sourcepub fn as_string_vector(&self) -> Option<Vec<String>>
pub fn as_string_vector(&self) -> Option<Vec<String>>
Get a vector of owned strings. Owned strings have long lifetimes, but are much slower than references.
use extendr_api::prelude::*;
test! {
let robj1 = Robj::from("xyz");
assert_eq!(robj1.as_string_vector(), Some(vec!["xyz".to_string()]));
let robj2 = Robj::from(1);
assert_eq!(robj2.as_string_vector(), None);
}
sourcepub fn as_str_vector(&self) -> Option<Vec<&str>>
pub fn as_str_vector(&self) -> Option<Vec<&str>>
Get a vector of string references. String references (&str) are faster, but have short lifetimes.
use extendr_api::prelude::*;
test! {
let robj1 = Robj::from("xyz");
assert_eq!(robj1.as_str_vector(), Some(vec!["xyz"]));
let robj2 = Robj::from(1);
assert_eq!(robj2.as_str_vector(), None);
}
sourcepub fn as_str<'a>(&self) -> Option<&'a str>
pub fn as_str<'a>(&self) -> Option<&'a str>
Get a read-only reference to a scalar string type.
use extendr_api::prelude::*;
test! {
let robj1 = Robj::from("xyz");
let robj2 = Robj::from(1);
assert_eq!(robj1.as_str(), Some("xyz"));
assert_eq!(robj2.as_str(), None);
}
sourcepub fn as_integer(&self) -> Option<i32>
pub fn as_integer(&self) -> Option<i32>
Get a scalar integer.
use extendr_api::prelude::*;
test! {
let robj1 = Robj::from("xyz");
let robj2 = Robj::from(1);
let robj3 = Robj::from(NA_INTEGER);
assert_eq!(robj1.as_integer(), None);
assert_eq!(robj2.as_integer(), Some(1));
assert_eq!(robj3.as_integer(), None);
}
sourcepub fn as_real(&self) -> Option<f64>
pub fn as_real(&self) -> Option<f64>
Get a scalar real.
use extendr_api::prelude::*;
test! {
let robj1 = Robj::from(1);
let robj2 = Robj::from(1.);
let robj3 = Robj::from(NA_REAL);
assert_eq!(robj1.as_real(), None);
assert_eq!(robj2.as_real(), Some(1.));
assert_eq!(robj3.as_real(), None);
}
sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Get a scalar rust boolean.
use extendr_api::prelude::*;
test! {
let robj1 = Robj::from(TRUE);
let robj2 = Robj::from(1.);
let robj3 = Robj::from(NA_LOGICAL);
assert_eq!(robj1.as_bool(), Some(true));
assert_eq!(robj2.as_bool(), None);
assert_eq!(robj3.as_bool(), None);
}
sourcepub fn as_logical(&self) -> Option<Rbool>
pub fn as_logical(&self) -> Option<Rbool>
Get a scalar boolean as a tri-boolean Rbool value.
use extendr_api::prelude::*;
test! {
let robj1 = Robj::from(TRUE);
let robj2 = Robj::from([TRUE, FALSE]);
let robj3 = Robj::from(NA_LOGICAL);
assert_eq!(robj1.as_logical(), Some(TRUE));
assert_eq!(robj2.as_logical(), None);
assert_eq!(robj3.as_logical().unwrap().is_na(), true);
}
Trait Implementations§
source§impl<Rhs> Add<Rhs> for Robjwhere
Rhs: Into<Robj>,
impl<Rhs> Add<Rhs> for Robjwhere Rhs: Into<Robj>,
source§fn add(self, rhs: Rhs) -> Self::Output
fn add(self, rhs: Rhs) -> Self::Output
Add two R objects, consuming the left hand side. panics on error.
use extendr_api::prelude::*;
test! {
// lhs and rhs get dropped here
let lhs = r!([1, 2]);
let rhs = r!([10, 20]);
assert_eq!(lhs + rhs, r!([11, 22]));
// lhs gets dropped and rhs is a temporary object.
let lhs = r!([1, 2]);
assert_eq!(lhs + 1000, r!([1001, 1002]));
// Only lhs gets dropped.
let lhs = r!([1, 2]);
let rhs = r!([10, 20]);
assert_eq!(lhs + &rhs, r!([11, 22]));
}
source§impl<'a> AsTypedSlice<'a, Rbool> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, Rbool> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [Rbool]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [Rbool]>
source§impl<'a> AsTypedSlice<'a, Rcomplex> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, Rcomplex> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [Rcomplex]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [Rcomplex]>
source§impl<'a> AsTypedSlice<'a, Rcplx> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, Rcplx> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [Rcplx]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [Rcplx]>
source§impl<'a> AsTypedSlice<'a, Rfloat> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, Rfloat> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [Rfloat]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [Rfloat]>
source§impl<'a> AsTypedSlice<'a, Rint> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, Rint> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [Rint]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [Rint]>
source§impl<'a> AsTypedSlice<'a, Robj> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, Robj> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [Robj]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [Robj]>
source§impl<'a> AsTypedSlice<'a, Rstr> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, Rstr> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [Rstr]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [Rstr]>
source§impl<'a> AsTypedSlice<'a, c64> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, c64> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [c64]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [c64]>
source§impl<'a> AsTypedSlice<'a, f64> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, f64> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [f64]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [f64]>
source§impl<'a> AsTypedSlice<'a, i32> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, i32> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [i32]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [i32]>
source§impl<'a> AsTypedSlice<'a, u32> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, u32> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [u32]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [u32]>
source§impl<'a> AsTypedSlice<'a, u8> for Robjwhere
Self: 'a,
impl<'a> AsTypedSlice<'a, u8> for Robjwhere Self: 'a,
fn as_typed_slice(&self) -> Option<&'a [u8]>
fn as_typed_slice_mut(&mut self) -> Option<&'a mut [u8]>
source§impl Attributes for Robj
impl Attributes for Robj
source§fn get_attrib<'a, N>(&self, name: N) -> Option<Robj>where
Self: 'a,
Robj: From<N> + 'a,
fn get_attrib<'a, N>(&self, name: N) -> Option<Robj>where Self: 'a, Robj: From<N> + 'a,
source§fn has_attrib<'a, N>(&self, name: N) -> boolwhere
Self: 'a,
Robj: From<N> + 'a,
fn has_attrib<'a, N>(&self, name: N) -> boolwhere Self: 'a, Robj: From<N> + 'a,
source§fn set_attrib<N, V>(&self, name: N, value: V) -> Result<Robj>where
N: Into<Robj>,
V: Into<Robj>,
fn set_attrib<N, V>(&self, name: N, value: V) -> Result<Robj>where N: Into<Robj>, V: Into<Robj>,
source§fn names(&self) -> Option<StrIter>
fn names(&self) -> Option<StrIter>
source§fn set_names<T>(&mut self, names: T) -> Result<Robj>where
T: IntoIterator,
T::IntoIter: ExactSizeIterator,
T::Item: ToVectorValue + AsRef<str>,
fn set_names<T>(&mut self, names: T) -> Result<Robj>where T: IntoIterator, T::IntoIter: ExactSizeIterator, T::Item: ToVectorValue + AsRef<str>,
source§fn dim(&self) -> Option<Integers>
fn dim(&self) -> Option<Integers>
source§fn dimnames(&self) -> Option<ListIter>
fn dimnames(&self) -> Option<ListIter>
source§fn class(&self) -> Option<StrIter>
fn class(&self) -> Option<StrIter>
source§fn set_class<T>(&self, class: T) -> Result<Robj>where
T: IntoIterator,
T::IntoIter: ExactSizeIterator,
T::Item: ToVectorValue + AsRef<str>,
fn set_class<T>(&self, class: T) -> Result<Robj>where T: IntoIterator, T::IntoIter: ExactSizeIterator, T::Item: ToVectorValue + AsRef<str>,
source§impl Conversions for Robj
impl Conversions for Robj
source§fn as_language(&self) -> Option<Language>
fn as_language(&self) -> Option<Language>
source§fn as_pairlist(&self) -> Option<Pairlist>
fn as_pairlist(&self) -> Option<Pairlist>
source§fn as_expressions(&self) -> Option<Expressions>
fn as_expressions(&self) -> Option<Expressions>
source§fn as_environment(&self) -> Option<Environment>
fn as_environment(&self) -> Option<Environment>
source§fn as_function(&self) -> Option<Function>
fn as_function(&self) -> Option<Function>
source§fn as_promise(&self) -> Option<Promise>
fn as_promise(&self) -> Option<Promise>
source§impl<Rhs> Div<Rhs> for Robjwhere
Rhs: Into<Robj>,
impl<Rhs> Div<Rhs> for Robjwhere Rhs: Into<Robj>,
source§fn div(self, rhs: Rhs) -> Self::Output
fn div(self, rhs: Rhs) -> Self::Output
Divide two R objects, consuming the left hand side. panics on error.
use extendr_api::prelude::*;
test! {
// lhs and rhs get dropped here
let lhs = r!([10.0, 20.0]);
let rhs = r!([1.0, 2.0]);
assert_eq!(lhs / rhs, r!([10.0, 10.0]));
// lhs gets dropped and rhs is a temporary object.
let lhs = r!([10.0, 30.0]);
assert_eq!(lhs / 10.0, r!([1.0, 3.0]));
// Only lhs gets dropped.
let lhs = r!([10.0, 20.0]);
let rhs = r!([1.0, 2.0]);
assert_eq!(lhs / &rhs, r!([10.0, 10.0]));
}
source§impl Eval for Robj
impl Eval for Robj
source§fn eval(&self) -> Result<Robj>
fn eval(&self) -> Result<Robj>
source§fn eval_with_env(&self, env: &Environment) -> Result<Robj>
fn eval_with_env(&self, env: &Environment) -> Result<Robj>
source§fn eval_blind(&self) -> Robj
fn eval_blind(&self) -> Robj
source§impl From<&Environment> for Robj
impl From<&Environment> for Robj
source§fn from(val: &Environment) -> Self
fn from(val: &Environment) -> Self
Make an robj from a wrapper.
source§impl From<&Expressions> for Robj
impl From<&Expressions> for Robj
source§fn from(val: &Expressions) -> Self
fn from(val: &Expressions) -> Self
Make an robj from a wrapper.
source§impl From<Environment> for Robj
impl From<Environment> for Robj
source§fn from(val: Environment) -> Self
fn from(val: Environment) -> Self
Make an robj from a wrapper.
source§impl From<Expressions> for Robj
impl From<Expressions> for Robj
source§fn from(val: Expressions) -> Self
fn from(val: Expressions) -> Self
Make an robj from a wrapper.
source§impl<T: Any + Debug> From<ExternalPtr<T>> for Robj
impl<T: Any + Debug> From<ExternalPtr<T>> for Robj
source§fn from(val: ExternalPtr<T>) -> Self
fn from(val: ExternalPtr<T>) -> Self
source§impl From<PairlistIter> for Robj
impl From<PairlistIter> for Robj
source§fn from(iter: PairlistIter) -> Self
fn from(iter: PairlistIter) -> Self
You can return a PairlistIter from a function.
source§impl<T> From<Range<T>> for Robjwhere
Range<T>: RobjItertools,
<Range<T> as Iterator>::Item: ToVectorValue,
T: ToVectorValue,
impl<T> From<Range<T>> for Robjwhere Range<T>: RobjItertools, <Range<T> as Iterator>::Item: ToVectorValue, T: ToVectorValue,
source§impl<T> From<RangeInclusive<T>> for Robjwhere
RangeInclusive<T>: RobjItertools,
<RangeInclusive<T> as Iterator>::Item: ToVectorValue,
T: ToVectorValue,
impl<T> From<RangeInclusive<T>> for Robjwhere RangeInclusive<T>: RobjItertools, <RangeInclusive<T> as Iterator>::Item: ToVectorValue, T: ToVectorValue,
source§fn from(val: RangeInclusive<T>) -> Self
fn from(val: RangeInclusive<T>) -> Self
source§impl<T> From<Result<T, Error>> for Robjwhere
T: Into<Robj>,
impl<T> From<Result<T, Error>> for Robjwhere T: Into<Robj>,
Convert a Result to an Robj. This is used to allow
functions to use the ? operator and return Result
Panics if there is an error.
use extendr_api::prelude::*;
fn my_func() -> Result<f64> {
Ok(1.0)
}
test! {
assert_eq!(r!(my_func()), r!(1.0));
}
source§impl<T> From<T> for Robjwhere
T: ToVectorValue,
impl<T> From<T> for Robjwhere T: ToVectorValue,
source§impl Load for Robj
impl Load for Robj
source§fn load<P: AsRef<Path>>(
path: &P,
format: PstreamFormat,
hook: Option<ReadHook>
) -> Result<Robj>
fn load<P: AsRef<Path>>( path: &P, format: PstreamFormat, hook: Option<ReadHook> ) -> Result<Robj>
version
should probably be 3.source§fn from_reader<R: Read>(
reader: &mut R,
format: PstreamFormat,
hook: Option<ReadHook>
) -> Result<Robj>
fn from_reader<R: Read>( reader: &mut R, format: PstreamFormat, hook: Option<ReadHook> ) -> Result<Robj>
Write
trait.
version
should probably be 3.source§impl MatrixConversions for Robj
impl MatrixConversions for Robj
source§impl<Rhs> Mul<Rhs> for Robjwhere
Rhs: Into<Robj>,
impl<Rhs> Mul<Rhs> for Robjwhere Rhs: Into<Robj>,
source§fn mul(self, rhs: Rhs) -> Self::Output
fn mul(self, rhs: Rhs) -> Self::Output
Multiply two R objects, consuming the left hand side. panics on error.
use extendr_api::prelude::*;
test! {
// lhs and rhs get dropped here
let lhs = r!([10.0, 20.0]);
let rhs = r!([1.0, 2.0]);
assert_eq!(lhs * rhs, r!([10.0, 40.0]));
// lhs gets dropped and rhs is a temporary object.
let lhs = r!([1.0, 2.0]);
assert_eq!(lhs * 10.0, r!([10.0, 20.0]));
// Only lhs gets dropped.
let lhs = r!([10.0, 20.0]);
let rhs = r!([1.0, 2.0]);
assert_eq!(lhs * &rhs, r!([10.0, 40.0]));
}
source§impl Operators for Robj
impl Operators for Robj
source§fn dollar<T>(&self, symbol: T) -> Result<Robj>where
T: AsRef<str>,
fn dollar<T>(&self, symbol: T) -> Result<Robj>where T: AsRef<str>,
source§fn slice<T>(&self, rhs: T) -> Result<Robj>where
T: Into<Robj>,
fn slice<T>(&self, rhs: T) -> Result<Robj>where T: Into<Robj>,
x[y]
Read moresource§fn index<T>(&self, rhs: T) -> Result<Robj>where
T: Into<Robj>,
fn index<T>(&self, rhs: T) -> Result<Robj>where T: Into<Robj>,
x[[y]]
Read moresource§fn tilde<T>(&self, rhs: T) -> Result<Robj>where
T: Into<Robj>,
fn tilde<T>(&self, rhs: T) -> Result<Robj>where T: Into<Robj>,
source§impl Rinternals for Robj
impl Rinternals for Robj
source§fn is_logical(&self) -> bool
fn is_logical(&self) -> bool
source§fn is_complex(&self) -> bool
fn is_complex(&self) -> bool
source§fn is_expressions(&self) -> bool
fn is_expressions(&self) -> bool
source§fn is_environment(&self) -> bool
fn is_environment(&self) -> bool
source§fn is_promise(&self) -> bool
fn is_promise(&self) -> bool
source§fn is_external_pointer(&self) -> bool
fn is_external_pointer(&self) -> bool
source§fn get_current_srcref(val: i32) -> Robj
fn get_current_srcref(val: i32) -> Robj
source§fn get_src_filename(&self) -> Robj
fn get_src_filename(&self) -> Robj
source§fn as_character_vector(&self) -> Robj
fn as_character_vector(&self) -> Robj
source§fn coerce_vector(&self, sexptype: u32) -> Robj
fn coerce_vector(&self, sexptype: u32) -> Robj
source§fn pair_to_vector_list(&self) -> Robj
fn pair_to_vector_list(&self) -> Robj
source§fn vector_to_pair_list(&self) -> Robj
fn vector_to_pair_list(&self) -> Robj
source§fn as_character_factor(&self) -> Robj
fn as_character_factor(&self) -> Robj
source§fn duplicate(&self) -> Robj
fn duplicate(&self) -> Robj
source§fn find_function<K: TryInto<Symbol, Error = Error>>(
&self,
key: K
) -> Result<Robj>
fn find_function<K: TryInto<Symbol, Error = Error>>( &self, key: K ) -> Result<Robj>
source§fn find_var<K: TryInto<Symbol, Error = Error>>(&self, key: K) -> Result<Robj>
fn find_var<K: TryInto<Symbol, Error = Error>>(&self, key: K) -> Result<Robj>
source§fn eval_promise(&self) -> Result<Robj>
fn eval_promise(&self) -> Result<Robj>
source§fn xlengthgets(&self, new_len: usize) -> Result<Robj>
fn xlengthgets(&self, new_len: usize) -> Result<Robj>
source§fn alloc_vector(sexptype: u32, len: usize) -> Robj
fn alloc_vector(sexptype: u32, len: usize) -> Robj
source§fn is_function(&self) -> bool
fn is_function(&self) -> bool
source§fn is_integer(&self) -> bool
fn is_integer(&self) -> bool
source§fn is_language(&self) -> bool
fn is_language(&self) -> bool
source§fn is_pairlist(&self) -> bool
fn is_pairlist(&self) -> bool
source§fn is_number(&self) -> bool
fn is_number(&self) -> bool
source§fn is_primitive(&self) -> bool
fn is_primitive(&self) -> bool
source§fn is_user_binop(&self) -> bool
fn is_user_binop(&self) -> bool
source§fn is_valid_string(&self) -> bool
fn is_valid_string(&self) -> bool
source§fn is_valid_string_f(&self) -> bool
fn is_valid_string_f(&self) -> bool
source§fn is_vector_atomic(&self) -> bool
fn is_vector_atomic(&self) -> bool
source§fn is_vector_list(&self) -> bool
fn is_vector_list(&self) -> bool
source§fn is_vectorizable(&self) -> bool
fn is_vectorizable(&self) -> bool
fn is_missing_arg(&self) -> bool
fn is_unbound_value(&self) -> bool
fn is_package_env(&self) -> bool
fn package_env_name(&self) -> Robj
fn is_namespace_env(&self) -> bool
fn namespace_env_spec(&self) -> Robj
source§fn is_altinteger(&self) -> bool
fn is_altinteger(&self) -> bool
true
if this is an integer ALTREP object.source§fn is_altreal(&self) -> bool
fn is_altreal(&self) -> bool
true
if this is an real ALTREP object.source§fn is_altlogical(&self) -> bool
fn is_altlogical(&self) -> bool
true
if this is an logical ALTREP object.source§fn is_altstring(&self) -> bool
fn is_altstring(&self) -> bool
true
if this is an integer ALTREP object.source§impl<Rhs> Sub<Rhs> for Robjwhere
Rhs: Into<Robj>,
impl<Rhs> Sub<Rhs> for Robjwhere Rhs: Into<Robj>,
source§fn sub(self, rhs: Rhs) -> Self::Output
fn sub(self, rhs: Rhs) -> Self::Output
Subtract two R objects, consuming the left hand side. panics on error.
use extendr_api::prelude::*;
test! {
// lhs and rhs get dropped here
let lhs = r!([10, 20]);
let rhs = r!([1, 2]);
assert_eq!(lhs - rhs, r!([9, 18]));
// lhs gets dropped and rhs is a temporary object.
let lhs = r!([1000, 2000]);
assert_eq!(lhs - 1, r!([999, 1999]));
// Only lhs gets dropped.
let lhs = r!([10, 20]);
let rhs = r!([1, 2]);
assert_eq!(lhs - &rhs, r!([9, 18]));
}
source§impl<'a, T> TryFrom<&'a Robj> for Nullable<T>where
T: TryFrom<&'a Robj, Error = Error>,
impl<'a, T> TryFrom<&'a Robj> for Nullable<T>where T: TryFrom<&'a Robj, Error = Error>,
source§fn try_from(robj: &'a Robj) -> Result<Self, Self::Error>
fn try_from(robj: &'a Robj) -> Result<Self, Self::Error>
Convert an object that may be null to a rust type.
use extendr_api::prelude::*;
test! {
let s1 = r!(1);
let n1 = <Nullable<i32>>::try_from(&s1)?;
assert_eq!(n1, Nullable::NotNull(1));
let snull = r!(NULL);
let nnull = <Nullable<i32>>::try_from(&snull)?;
assert_eq!(nnull, Nullable::Null);
}
source§impl TryFrom<&Robj> for Environment
impl TryFrom<&Robj> for Environment
source§impl TryFrom<&Robj> for Expressions
impl TryFrom<&Robj> for Expressions
source§impl<T> TryFrom<&Robj> for FromList<Vec<T>>where
T: TryFrom<Robj>,
<T as TryFrom<Robj>>::Error: Into<Error>,
impl<T> TryFrom<&Robj> for FromList<Vec<T>>where T: TryFrom<Robj>, <T as TryFrom<Robj>>::Error: Into<Error>,
source§impl TryFrom<&Robj> for PairlistIter
impl TryFrom<&Robj> for PairlistIter
source§impl TryFrom<&Robj> for Vec<Rfloat>
impl TryFrom<&Robj> for Vec<Rfloat>
source§impl TryFrom<&Robj> for Vec<f64>
impl TryFrom<&Robj> for Vec<f64>
source§impl TryFrom<Robj> for Environment
impl TryFrom<Robj> for Environment
source§impl TryFrom<Robj> for Expressions
impl TryFrom<Robj> for Expressions
source§impl<T> TryFrom<Robj> for FromList<Vec<T>>where
T: TryFrom<Robj>,
<T as TryFrom<Robj>>::Error: Into<Error>,
impl<T> TryFrom<Robj> for FromList<Vec<T>>where T: TryFrom<Robj>, <T as TryFrom<Robj>>::Error: Into<Error>,
source§impl<T> TryFrom<Robj> for Nullable<T>where
T: TryFrom<Robj, Error = Error>,
impl<T> TryFrom<Robj> for Nullable<T>where T: TryFrom<Robj, Error = Error>,
source§fn try_from(robj: Robj) -> Result<Self, Self::Error>
fn try_from(robj: Robj) -> Result<Self, Self::Error>
Convert an object that may be null to a rust type.
use extendr_api::prelude::*;
test! {
let s1 = r!(1);
let n1 = <Nullable<i32>>::try_from(s1)?;
assert_eq!(n1, Nullable::NotNull(1));
let snull = r!(NULL);
let nnull = <Nullable<i32>>::try_from(snull)?;
assert_eq!(nnull, Nullable::Null);
}