Is your feature request related to a problem or challenge? Please describe what you are trying to do.
After @scovich's PR to validate objects on construction
I expected to be able to use the APIs for variant without havin to check for errors. Also I found the field_by_name very confusing as I expected get() to retrieve a field of a Variant object but instead it was called field_by_name.
Describe the solution you'd like
I want APIs that are infallible (don't return errors) so they are easier to work with
Describe alternatives you've considered
I would personally like to write
let variant_object = variant.as_object().unwrap()
// retrieve the value from a field as Option<Variant>
assert_eq!(variant_object.get("my_field"), Some(Variant::from("foo")));
// non existent fields return None
assert_eq!(variant_object.get("my_non_existent)field"), None);
Likewise for VariantLists I would like to do
let variant_list = variant.as_list().unwrap();
// retrieve item at index 1
assert_eq!(variant_list.get(1), Some(Variant::from("foo")));
/// non existent items return None (like Rust slices)
assert_eq!(variant_list.get(100), None);
Additional context
I noticed this while working on
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
After @scovich's PR to validate objects on construction
I expected to be able to use the APIs for variant without havin to check for errors. Also I found the
field_by_namevery confusing as I expectedget()to retrieve a field of a Variant object but instead it was calledfield_by_name.Describe the solution you'd like
I want APIs that are infallible (don't return errors) so they are easier to work with
Describe alternatives you've considered
I would personally like to write
Likewise for VariantLists I would like to do
Additional context
I noticed this while working on