Skip to main content

IsNA

Derive Macro IsNA 

Source
#[derive(IsNA)]
Expand description

Derive IsNA for a native newtype by forwarding to its single field.

Supports tuple, named and generic newtypes that also implement RNativeType. The inner field must implement IsNA; existing where clauses are preserved. This derive is separate from RNativeType because raw u8 storage has no NA representation.

use miniextendr_api::{IsNA, RNativeType};

#[repr(transparent)]
#[derive(Clone, Copy, RNativeType, IsNA)]
struct Temperature { celsius: f64 }

assert!(Temperature::R_NA.is_na());
assert!(!Temperature { celsius: f64::NAN }.is_na());

A generic native wrapper supports raw bytes too, but its IsNA impl is available only when the inner type has NA:

ⓘ
use miniextendr_api::{IsNA, RNativeType};

#[repr(transparent)]
#[derive(Clone, Copy, RNativeType, IsNA)]
struct Native<T: RNativeType>(T);

fn requires_na<T: IsNA>() {}
requires_na::<Native<u8>>();