Trait extendr_api::robj::Types
source · [−]Provided methods
Get the type of an R object.
use extendr_api::prelude::*;
test! {
assert_eq!(r!(NULL).rtype(), Rtype::Null);
assert_eq!(sym!(xyz).rtype(), Rtype::Symbol);
assert_eq!(r!(Pairlist::from_pairs(vec![("a", r!(1))])).rtype(), Rtype::Pairlist);
assert_eq!(R!("function() {}")?.rtype(), Rtype::Function);
assert_eq!(Environment::new_with_parent(global_env()).rtype(), Rtype::Environment);
assert_eq!(lang!("+", 1, 2).rtype(), Rtype::Language);
assert_eq!(r!(Primitive::from_string("if")).rtype(), Rtype::Special);
assert_eq!(r!(Primitive::from_string("+")).rtype(), Rtype::Builtin);
assert_eq!(r!(Rstr::from_string("hello")).rtype(), Rtype::Rstr);
assert_eq!(r!(TRUE).rtype(), Rtype::Logicals);
assert_eq!(r!(1).rtype(), Rtype::Integers);
assert_eq!(r!(1.0).rtype(), Rtype::Doubles);
assert_eq!(r!("1").rtype(), Rtype::Strings);
assert_eq!(r!(List::from_values(&[1, 2])).rtype(), Rtype::List);
assert_eq!(parse("x + y")?.rtype(), Rtype::Expressions);
assert_eq!(r!(Raw::from_bytes(&[1_u8, 2, 3])).rtype(), Rtype::Raw);
}
Implementors
impl Types for Altrep
rtype() and rany()
impl Types for Complexes
rtype() and rany()
impl Types for Doubles
rtype() and rany()
impl Types for Environment
rtype() and rany()
impl Types for Expressions
rtype() and rany()
impl Types for Function
rtype() and rany()
impl Types for Integers
rtype() and rany()
impl Types for Language
rtype() and rany()
impl Types for List
rtype() and rany()
impl Types for Logicals
rtype() and rany()
impl Types for Pairlist
rtype() and rany()
impl Types for Primitive
rtype() and rany()
impl Types for Promise
rtype() and rany()
impl Types for Raw
rtype() and rany()
impl Types for Rstr
rtype() and rany()
impl Types for S4
rtype() and rany()
impl Types for Strings
rtype() and rany()
impl Types for Symbol
rtype() and rany()
impl Types for Robj
impl<T> Types for Dataframe<T>
rtype() and rany()
impl<T: Debug + 'static> Types for ExternalPtr<T>
rtype() and rany()