Skip to content

v0.6.3 (2024-05-05)

Compare
Choose a tag to compare
@github-actions github-actions released this 05 May 13:47
· 90 commits to main since this release

Release Notes

New features

  • New types NumericSexp and NumericScalar are added to handle both integer
    and double. You can get a slice via as_slice_*() or an iterator via
    iter_*().

    #[savvy]
    fn times_two(x: NumericSexp) -> savvy::Result<Sexp> {
        let mut out = OwnedIntegerSexp::new(x.len())?;
    
        for (i, v) in x.iter_i32().enumerate() {
            let v = v?; // The item of iter_i32() is Result because the conversion can fail.
            if v.is_na() {
                out[i] = i32::na();
            } else {
                out[i] = v * 2;
            }
        }
    
        out.into()
    }

    You can also use .into_typed() to handle integer and double differently.

    #[savvy]
    fn times_two(x: NumericSexp) -> savvy::Result<savvy::Sexp> {
        match x.into_typed() {
            NumericTypedSexp::Integer(i) => times_two_int(i),
            NumericTypedSexp::Real(r) => times_two_real(r),
        }
    }
  • Savvy now provides r_stdout() and r_stderr() to be used with interfaces
    that require std::io::Write. Also, you can use savvy::log::env_logger() to
    output logs to R's stderr. Here's an example usage:

    use savvy::savvy_init;
    use savvy_ffi::DllInfo;
    
    #[savvy_init]
    fn init_logger(dll_info: *mut DllInfo) -> savvy::Result<()> {
        savvy::log::env_logger().init();
        Ok(())
    }

Breaking changes

  • AltList now loses names argument in into_altrep() for consistency.
    Please use set_names() on the resulted Sexp object.

    let mut out = v.into_altrep()?;
    out.set_names(["one", "two"])?;
    Ok(out)

Download savvy-cli 0.6.3

File Platform Checksum
savvy-cli-aarch64-apple-darwin.tar.xz Apple Silicon macOS checksum
savvy-cli-x86_64-apple-darwin.tar.xz Intel macOS checksum
savvy-cli-x86_64-pc-windows-msvc.zip x64 Windows checksum
savvy-cli-aarch64-unknown-linux-gnu.tar.xz ARM64 Linux checksum
savvy-cli-x86_64-unknown-linux-gnu.tar.xz x64 Linux checksum