pass_single_raw: Left shift a raw value in Rust

Description Usage Arguments Details Value Examples

View source: R/extendr-wrappers.R

Description

Demonstrates passing a raw (byte) value back and forth between R and Rust, left shifting the value in Rust to prove it works.

Usage

1

Arguments

r

A raw value to treat as a byte in Rust

Details

The value passed to this function must be a raw, the byte type in R. The Rust function signature is fn pass_single_raw_fn(r: u8) -> u8. R does not support NAs for raw types. Currently, extendr (v0.2.0) supports passing in numbers from 0-255 instead of values from as.raw() as single values. Values below 0 are coerced to 0, values greater than 255 are coerced to 255.

Value

bitwShiftL(r, 1)

Examples

1
2
3
pass_single_raw(4)    # 8
pass_single_raw(-10)  # 0
pass_single_raw(300)  # 254

ericwburden/rustbind documentation built on April 10, 2021, 12:31 p.m.