Struct extendr_api::scalar::Rbool

source ·
pub struct Rbool(_);
Expand description

Rbool is a wrapper for i32 in the context of an R’s logical vector.

Rbool can have a value of 0, 1 or i32::MIN.

The value i32::MIN is used as “NA”.

Rbool has the same footprint as an i32 value allowing us to use it in zero copy slices.

Implementations§

source§

impl Rbool

source

pub fn inner(&self) -> i32

Get underlying value.

source

pub const fn true_value() -> Rbool

Return a true Rbool.

source

pub const fn false_value() -> Rbool

Return a false Rbool.

source

pub const fn na_value() -> Rbool

Return a NA Rbool.

source

pub fn is_true(&self) -> bool

Return true if this triboolean is true but not NA.

source

pub fn is_false(&self) -> bool

Return true if this triboolean is false but not NA.

source

pub fn to_bool(&self) -> bool

Convert this Rbool to a bool. Note NA will be true.

source

pub fn from_bool(val: bool) -> Self

Convert this construct a Rbool from a rust boolean.

Trait Implementations§

source§

impl<'a> AsTypedSlice<'a, Rbool> for Robjwhere Self: 'a,

source§

fn as_typed_slice(&self) -> Option<&'a [Rbool]>

source§

fn as_typed_slice_mut(&mut self) -> Option<&'a mut [Rbool]>

source§

impl CanBeNA for Rbool

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

fn is_na(&self) -> bool

Return true is the is a NA value.

source§

fn na() -> Self

Construct a NA.

source§

impl Clone for Rbool

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Rbool

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Debug format.

source§

impl Default for Rbool

use extendr_api::prelude::*;
test! {
    assert_eq!(<Rbool>::default(), <bool>::default());
}
source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<&i32> for Rbool

source§

fn from(v: &i32) -> Self

Converts to this type from the input type.
source§

impl From<Option<&i32>> for Rbool

source§

fn from(v: Option<&i32>) -> Self

Converts to this type from the input type.
source§

impl From<Option<bool>> for Rbool

source§

fn from(v: Option<bool>) -> Self

Converts to this type from the input type.
source§

impl From<Option<i32>> for Rbool

source§

fn from(v: Option<i32>) -> Self

Converts to this type from the input type.
source§

impl From<Rbool> for Option<bool>

source§

fn from(v: Rbool) -> Self

Converts to this type from the input type.
source§

impl From<bool> for Rbool

source§

fn from(v: bool) -> Self

Converts to this type from the input type.
source§

impl From<i32> for Rbool

source§

fn from(v: i32) -> Self

Converts to this type from the input type.
source§

impl FromIterator<Rbool> for Logicals

source§

fn from_iter<T: IntoIterator<Item = Rbool>>(iter: T) -> Self

A more generalised iterator collector for small vectors. Generates a non-ALTREP vector.

source§

impl Not for Rbool

§

type Output = Rbool

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl PartialEq<Rbool> for Rbool

use extendr_api::prelude::*;
test! {
    assert!(<Rbool>::default().eq(&<Rbool>::default()));
    assert!(!<Rbool>::na().eq(&<Rbool>::na()));
}
source§

fn eq(&self, other: &Rbool) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<bool> for &Rbool

use extendr_api::prelude::*;
test! {
    assert!(<Rbool>::default().eq(&<bool>::default()));
}
source§

fn eq(&self, other: &bool) -> bool

NA always fails.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<bool> for Rbool

use extendr_api::prelude::*;
test! {
    assert!(<Rbool>::default().eq(&<bool>::default()));
}
source§

fn eq(&self, other: &bool) -> bool

NA always fails.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToVectorValue for &Rbool

source§

fn sexptype() -> SEXPTYPE

source§

fn to_logical(&self) -> i32where Self: Sized,

source§

fn to_real(&self) -> f64where Self: Sized,

source§

fn to_complex(&self) -> Rcomplexwhere Self: Sized,

source§

fn to_integer(&self) -> i32where Self: Sized,

source§

fn to_raw(&self) -> u8where Self: Sized,

source§

fn to_sexp(&self) -> SEXPwhere Self: Sized,

source§

impl ToVectorValue for Rbool

source§

fn sexptype() -> SEXPTYPE

source§

fn to_logical(&self) -> i32where Self: Sized,

source§

fn to_real(&self) -> f64where Self: Sized,

source§

fn to_complex(&self) -> Rcomplexwhere Self: Sized,

source§

fn to_integer(&self) -> i32where Self: Sized,

source§

fn to_raw(&self) -> u8where Self: Sized,

source§

fn to_sexp(&self) -> SEXPwhere Self: Sized,

source§

impl TryFrom<&Robj> for Rbool

source§

fn try_from(robj: &Robj) -> Result<Self>

Convert an LGLSXP object into a Rbool (tri-state boolean). Use value.is_na() to detect NA values.

§

type Error = Error

The type returned in the event of a conversion error.
source§

impl TryFrom<Robj> for Rbool

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(robj: Robj) -> Result<Self>

Performs the conversion.
source§

impl Copy for Rbool

Auto Trait Implementations§

§

impl RefUnwindSafe for Rbool

§

impl Send for Rbool

§

impl Sync for Rbool

§

impl Unpin for Rbool

§

impl UnwindSafe for Rbool

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.