pub trait Operators: Rinternals {
// Provided methods
fn dollar<T>(&self, symbol: T) -> Result<Robj>
where T: AsRef<str> { ... }
fn slice<T>(&self, rhs: T) -> Result<Robj>
where T: Into<Robj> { ... }
fn index<T>(&self, rhs: T) -> Result<Robj>
where T: Into<Robj> { ... }
fn tilde<T>(&self, rhs: T) -> Result<Robj>
where T: Into<Robj> { ... }
fn double_colon<T>(&self, rhs: T) -> Result<Robj>
where T: Into<Robj> { ... }
fn call(&self, args: Pairlist) -> Result<Robj> { ... }
}
Expand description
The following impls add operators to Robj.
Provided Methods§
Sourcefn dollar<T>(&self, symbol: T) -> Result<Robj>
fn dollar<T>(&self, symbol: T) -> Result<Robj>
Do the equivalent of x$y
use extendr_api::prelude::*;
test! {
let env = Environment::from_pairs(global_env(),
vec![("a".to_string(), r!(1)), ("b".to_string(), r!(2))]);
assert_eq!(env.dollar("a").unwrap(), r!(1));
assert_eq!(env.dollar("b").unwrap(), r!(2));
}
Sourcefn slice<T>(&self, rhs: T) -> Result<Robj>
fn slice<T>(&self, rhs: T) -> Result<Robj>
Do the equivalent of x[y]
use extendr_api::prelude::*;
test! {
let vec = r!([10, 20, 30]);
assert_eq!(vec.slice(2).unwrap(), r!(20));
assert_eq!(vec.slice(2..=3).unwrap(), r!([20, 30]));
}
Sourcefn index<T>(&self, rhs: T) -> Result<Robj>
fn index<T>(&self, rhs: T) -> Result<Robj>
Do the equivalent of x[[y]]
use extendr_api::prelude::*;
test! {
let vec = r!([10, 20, 30]);
assert_eq!(vec.index(2).unwrap(), r!(20));
assert_eq!(vec.index(2..=3).is_err(), true);
}
Sourcefn tilde<T>(&self, rhs: T) -> Result<Robj>
fn tilde<T>(&self, rhs: T) -> Result<Robj>
Do the equivalent of x ~ y
use extendr_api::prelude::*;
test! {
let x = r!(Symbol::from_string("x"));
let y = r!(Symbol::from_string("y"));
let tilde = x.tilde(y).unwrap();
assert_eq!(tilde.inherits("formula"), true);
}
Sourcefn double_colon<T>(&self, rhs: T) -> Result<Robj>
fn double_colon<T>(&self, rhs: T) -> Result<Robj>
Do the equivalent of x :: y
use extendr_api::prelude::*;
test! {
let base = r!(Symbol::from_string("base"));
let list = r!(Symbol::from_string("list"));
let base_list = base.double_colon(list).unwrap();
assert_eq!(base_list.is_function(), true);
}
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl Operators for Altrep
dollar() etc.
impl Operators for Complexes
dollar() etc.
impl Operators for Doubles
dollar() etc.
impl Operators for Environment
dollar() etc.
impl Operators for Expressions
dollar() etc.
impl Operators for Function
dollar() etc.
impl Operators for Integers
dollar() etc.
impl Operators for Language
dollar() etc.
impl Operators for List
dollar() etc.
impl Operators for Logicals
dollar() etc.
impl Operators for Pairlist
dollar() etc.
impl Operators for Primitive
dollar() etc.
impl Operators for Promise
dollar() etc.
impl Operators for Raw
dollar() etc.
impl Operators for Rstr
dollar() etc.
impl Operators for S4
dollar() etc.
impl Operators for Strings
dollar() etc.
impl Operators for Symbol
dollar() etc.
impl Operators for Robj
impl<T> Operators for Dataframe<T>
dollar() etc.
impl<T> Operators for ExternalPtr<T>
dollar() etc.