Skip to content

Structures API should support deref coercion #400

@ufoscout

Description

@ufoscout

The current API implementation does not support deref coercion like the standard Rust collections. In some cases, this forces a redundant instantiation only for retrieving data. E.g.:

    #[test]
    fn should_allow_retrieving_with_deref_types() {
        let mem = make_memory();
        let mut btree: BTreeMap<String, u64, _> = BTreeMap::new(mem.clone());
        btree.insert("foo".to_string(), 42);

        // This one works but it forces a useless instantiation of a new String
        assert_eq!(btree.get(&"foo".to_string()), Some(42)); // OK

        // This does not compile because the API strictly expects a `&String` type
        assert_eq!(btree.get("foo"), Some(42)); 
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions