thlorenz / rid

Rust integrated Dart framework providing an easy way to build Flutter apps with Rust.
64 stars 4 forks source link

feat: more key/val hash_map types for field access #24

Closed thlorenz closed 2 years ago

thlorenz commented 2 years ago

Added a few more types that HashMap field access now supports. Namely key + val can now be different types (before that wasn't properly implemented and the key type applied to the value as well).

The String type is now supported for keys (not yet for values). rid::model structs are now supported as value types.

Here's a summary from the accompanying tests (note that more key/val types may be supported, but haven't tested yet).

// -----------------
// Primitives key/val same type
// -----------------
u8s: HashMap<u8, u8>,
u32s: HashMap<u32, u32>,
i8s: HashMap<i8, i8>,
i64s: HashMap<i64, i64>,
// -----------------
// Primitives key/val different types
// -----------------
u8_i8s: HashMap<u8, i8>,
i64_u32s: HashMap<i64, u32>,

// -----------------
// Strings
// -----------------
string_u8s: HashMap<String, u8>,
string_points: HashMap<String, Point>,

Note that now all hash_map access methods use rid::export under the hood.

Thus in order to support String value types we need to implement more rid::export types first.