Skip to main content

CanBeNA

Trait CanBeNA 

Source
pub trait CanBeNA {
    // Required methods
    fn is_na(&self) -> bool;
    fn na() -> Self;
}
Expand description

Return true if this primitive is NA.

Required Methods§

Source

fn is_na(&self) -> bool

Source

fn na() -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl CanBeNA for &str

Special “NA” string that represents null strings.

use extendr_api::prelude::*;
test! {
    assert_ne!(<&str>::na().as_ptr(), "NA".as_ptr());
    assert_eq!(<&str>::na(), "NA");
    assert_eq!("NA".is_na(), false);
    assert_eq!(<&str>::na().is_na(), true);
}
Source§

fn is_na(&self) -> bool

Check for NA in a string by address.

Source§

fn na() -> Self

Source§

impl CanBeNA for Rcomplex

Source§

fn is_na(&self) -> bool

Source§

fn na() -> Self

Source§

impl CanBeNA for f64

use extendr_api::prelude::*;
test! {
    assert!(f64::na().is_na());
}
Source§

fn is_na(&self) -> bool

Source§

fn na() -> f64

Source§

impl CanBeNA for i32

use extendr_api::prelude::*;
test! {
    assert!(i32::na().is_na());
}
Source§

fn is_na(&self) -> bool

Source§

fn na() -> i32

Source§

impl CanBeNA for u8

Source§

fn is_na(&self) -> bool

Returns false always as u8/Raw cannot be NA in the traditional sense.

Source§

fn na() -> Self

Returns 0_u8 as the NA value for u8/Raw.

Note that this follows the convention of R, by using the minimum as the sentinel value.

Implementors§

Source§

impl CanBeNA for Rbool

use extendr_api::prelude::*;
test! {
    assert!((<Rbool>::na()).is_na());
}
Source§

impl CanBeNA for Rcplx

use extendr_api::prelude::*;
test! {
    assert!((<Rcplx>::na()).is_na());
}
Source§

impl CanBeNA for Rfloat

use extendr_api::prelude::*;
test! {
    assert!((<Rfloat>::na()).is_na());
}
Source§

impl CanBeNA for Rint

use extendr_api::prelude::*;
test! {
    assert!((<Rint>::na()).is_na());
}
Source§

impl CanBeNA for Rstr

Source§

impl CanBeNA for c64