Skip to main content

Module prelude

Module prelude 

Source
Expand description

Convenience re-exports for common miniextendr items.

A single use miniextendr_api::prelude::*; brings into scope the most commonly used macros, traits, types, and helpers. Convenience re-exports for common miniextendr items.

A single use miniextendr_api::prelude::*; brings into scope the most commonly used macros, traits, types, and helpers so user crates can avoid a long list of individual imports.

§Optional feature types

When a Cargo feature is enabled (e.g., uuid, regex, ndarray), the prelude includes both the miniextendr adapter types and a re-export of the upstream dependency crate itself. This means you do not need to add optional crates as direct dependencies in your Cargo.toml — enabling the feature on miniextendr-api is enough.

[dependencies]
miniextendr-api = { version = "0.1", features = ["uuid", "ndarray"] }
# No need for: uuid = "1", ndarray = "0.16"

Access the upstream crate via the prelude:

use miniextendr_api::prelude::*;

// Uuid is re-exported from the uuid crate
let id = Uuid::new_v4();

// The full crate is also available for advanced usage
let parsed = uuid::Uuid::parse_str("...").unwrap();

§Example

use miniextendr_api::prelude::*;

#[miniextendr]
fn add(a: i32, b: i32) -> i32 {
    a + b
}

Re-exports§

pub use crate::Altrep;
pub use crate::ExternalPtr;
pub use crate::MatchArg;
pub use crate::RFactor;
pub use crate::list;
pub use crate::typed_list;
pub use crate::Coerce;
pub use crate::IntoR;
pub use crate::IntoRAltrep;
pub use crate::TryCoerce;
pub use crate::TryFromSexp;
pub use crate::IntoList;
pub use crate::Lazy;
pub use crate::List;
pub use crate::ListBuilder;
pub use crate::ListMut;
pub use crate::Missing;
pub use crate::NamedVector;
pub use crate::OwnedProtect;
pub use crate::ProtectScope;
pub use crate::ProtectedStrVec;
pub use crate::StrVec;
pub use crate::StrVecBuilder;
pub use crate::with_r_thread;
pub use crate::r_warning;
pub use crate::ffi::SEXP;

Macros§

list
Construct an R list from Rust values.
r_print
Print to R’s console (like print!).
r_println
Print to R’s console with a newline (like println!).
typed_list
Create a TypedListSpec for validating ... arguments or lists.

Attribute Macros§

miniextendr
Export Rust items to R.

Derive Macros§

Altrep
Derive ALTREP registration for a data struct.
ExternalPtr
Derive macro for implementing TypedExternal on a type.
IntoList
Derive IntoList for a struct (Rust → R list).
MatchArg
Derive MatchArg: enables conversion between Rust enums and R character strings with match.arg semantics (partial matching, informative errors).
RFactor
Derive RFactor: enables conversion between Rust enums and R factors.