extendr_api::robj

Trait Types

Source
pub trait Types: GetSexp {
    // Provided methods
    fn rtype(&self) -> Rtype { ... }
    fn as_any(&self) -> Rany<'_> { ... }
}

Provided Methods§

Source

fn rtype(&self) -> Rtype

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!(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);
}
Source

fn as_any(&self) -> Rany<'_>

Implementors§

Source§

impl Types for Altrep

rtype() and rany()

Source§

impl Types for Complexes

rtype() and rany()

Source§

impl Types for Doubles

rtype() and rany()

Source§

impl Types for Environment

rtype() and rany()

Source§

impl Types for Expressions

rtype() and rany()

Source§

impl Types for Function

rtype() and rany()

Source§

impl Types for Integers

rtype() and rany()

Source§

impl Types for Language

rtype() and rany()

Source§

impl Types for List

rtype() and rany()

Source§

impl Types for Logicals

rtype() and rany()

Source§

impl Types for Pairlist

rtype() and rany()

Source§

impl Types for Primitive

rtype() and rany()

Source§

impl Types for Promise

rtype() and rany()

Source§

impl Types for Raw

rtype() and rany()

Source§

impl Types for Rstr

rtype() and rany()

Source§

impl Types for S4

rtype() and rany()

Source§

impl Types for Strings

rtype() and rany()

Source§

impl Types for Symbol

rtype() and rany()

Source§

impl Types for Robj

Source§

impl<T> Types for Dataframe<T>

rtype() and rany()

Source§

impl<T> Types for ExternalPtr<T>

rtype() and rany()