-
Notifications
You must be signed in to change notification settings - Fork 303
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
Add Support For The rust
Package
#2431
Comments
Looks interesting! I am not very sure whether e.g. |
Yeah supporting |
So I wonder whether |
I was referring more towards the logic in this package used to generate Dart code. But for your example, with Option<T> aOpt = f();
int a;
switch(aOpt) {
Some(:final v)
a = v;
default:
return;
}
print(a); Which is less desirable and this drawback is outline in the docs https://mcmah309.github.io/rust/libs/option/option.html#drawbacks Luckily int? a = f().value; // `f` returns an `Option<T>`
if (a==null) return;
print(a); // now a is `int`, not `int?` and can be used The main advantage of |
I see, thanks for the explanation! Then some brainstorms:
Btw curious how is |
It is try catch, but no StackTraces, so performace really depends on darts implementation. Theoretically the Dart compiler could compile But using early return is also completely up to the developer. You are never forced into it. I use it sometimes because, as you can imagine, it greatly reduces the need for |
rust implements many of Rust's types in Dart. It would be nice if a return type of
Result
in Rust generated a Result in Dart. Possibly for Option as well, sinceOption
is just an extension type ofT?
. Path is also just an extension type ofString
, opening the door for supporting returningPath
. Note that there is also the anyhow package built off rust as well. Meaninganyhow::Result
can also be supported.The text was updated successfully, but these errors were encountered: