-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NA handling #27
Comments
We also have |
Here's a minimal example of using this. @Ilia-Kosenkov what would you say the desired use pattern is for I can see it being helpful in my code here: https://github.com/JosiahParry/rsgeo/blob/32d0d7e2f0faab349b5261f964a0091760b55fcd/src/rust/src/boundary.rs#L149-L159 struct MyStruct();
#[extendr]
impl MyStruct {
}
#[extendr]
fn mynull(x: bool) -> Nullable<MyStruct> {
match x {
true => Nullable::NotNull(MyStruct()),
false => Nullable::Null,
}
} mynull(TRUE)
#> <pointer: 0x1>
#> attr(,"class")
#> [1] "MyStruct"
mynull(FALSE)
#> NULL |
I think one of the best use-cases is #[extendr(use_try_from = true)]
fn with_optional_input(#[default = "NULL"] idx : Nullable<Integers>) -> Integers {
match idx {
NotNull(x) => x,
Null => (0..5).collect::<Integers>() /* do not remember the syntax */
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use extendr types for inputs which allow for missing values. Illustrate using match or ifelse statements to handle missing values. Discuss options:
The text was updated successfully, but these errors were encountered: