59 releases

new 0.8.7 Mar 16, 2025
0.8.3 Jan 11, 2025
0.8.2 Dec 25, 2024
0.8.1 Nov 17, 2024
0.1.16 Oct 16, 2023

#185 in Procedural macros

Download history 126/week @ 2024-11-28 366/week @ 2024-12-05 439/week @ 2024-12-12 171/week @ 2024-12-19 48/week @ 2024-12-26 84/week @ 2025-01-02 559/week @ 2025-01-09 400/week @ 2025-01-16 186/week @ 2025-01-23 106/week @ 2025-01-30 733/week @ 2025-02-06 636/week @ 2025-02-13 511/week @ 2025-02-20 345/week @ 2025-02-27 185/week @ 2025-03-06 483/week @ 2025-03-13

1,575 downloads per month
Used in 3 crates (2 directly)

MIT license

94KB
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

~200–700KB
~17K SLoC