69 releases

new 0.9.0 Nov 24, 2025
0.8.13 Jul 28, 2025
0.8.8 Mar 26, 2025
0.8.2 Dec 25, 2024
0.1.16 Oct 16, 2023

#281 in Procedural macros

Download history 794/week @ 2025-08-05 480/week @ 2025-08-12 475/week @ 2025-08-19 494/week @ 2025-08-26 551/week @ 2025-09-02 523/week @ 2025-09-09 508/week @ 2025-09-16 806/week @ 2025-09-23 949/week @ 2025-09-30 1163/week @ 2025-10-07 687/week @ 2025-10-14 1071/week @ 2025-10-21 1071/week @ 2025-10-28 613/week @ 2025-11-04 864/week @ 2025-11-11 1521/week @ 2025-11-18

4,343 downloads per month
Used in 3 crates (2 directly)

MIT license

95KB
2.5K SLoC

savvy-bindgen

Parse Rust functions, and generate C and R code.

For the full details, please read savvy's crate documentation.

/// Convert to Upper-case
/// 
/// @param x A character vector.
/// @export
#[savvy]
fn to_upper(x: StringSexp) -> savvy::Result<savvy::Sexp> {
    // Use `Owned{type}Sexp` to allocate an R vector for output.
    let mut out = OwnedStringSexp::new(x.len())?;

    for (i, e) in x.iter().enumerate() {
        // To Rust, missing value is an ordinary value. In `&str`'s case, it's just "NA".
        // You have to use `.is_na()` method to distinguish the missing value.
        if e.is_na() {
            // Set the i-th element to NA
            out.set_na(i)?;
            continue;
        }

        let e_upper = e.to_uppercase();
        out.set_elt(i, e_upper.as_str())?;
    }

    out.into()
}

Dependencies

~160–640KB
~15K SLoC