Simple correspondence
Here is a brief glance showing what the code generator can generate (non-exhaustive). Some rows have hyper-links pointing to more detailed explanations.
Rust | Dart |
---|---|
Vec<u8> ..Vec<u64> | Uint8List ..Uint64List |
Vec<i8> ..Vec<i64> | Int8List ..Int64List |
Vec<f32> , Vec<f64> | Float32List , Float64List |
Vec<T> | List<T> |
[T; N] | List<T> |
struct { .. } , struct( .. ) | class |
enum { A, B } | enum |
enum { A(..) } | @freezed sealed class |
use ... | act normally |
Option<T> | T? |
Arbitrary Rust types (opaque) | RustOpaque |
DartOpaque | Arbitrary Dart types (opaque) |
Result::Err , panic | throw Exception |
Box<T> | T |
comments | same |
i8 , u8 , .., usize | int |
f32 , f64 | double |
bool | bool |
String | String |
() | void |
type A = B | type alias |
(T, U, ..) | (T, U, ..) |
Types from chrono
crate are supported as a feature, see here.
Types from uuid
crate are supported as a feature, see here.
Raw strings are supported for struct field names. For example, you can have struct S { r#type: i32 }
. In dart, the r#
prefix will be correctly removed. They are not yet supported for function arguments.