Structures API should support deref coercion
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- backend-api-design
Research direction
Start by locating the BTreeMap API implementation, especially its get method and existing key lookup behavior. Confirm how standard Rust collections handle borrowed or deref-compatible keys; done means btree.get("foo") works without constructing a temporary String while the existing lookup still works.
Written by the indexing model from the issue text.
Description
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));
}
- Dominant language
- Rust
- Stars
- 111
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dfinity/stable-structures
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
dfinity/stable-structures#439 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
dfinity/stable-structures#382 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
dfinity/stable-structures#349 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
dfinity/stable-structures#266 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
dfinity/stable-structures#264 · 1 comment ·
All issues in dfinity/stable-structures
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug team:backend track:services-maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cowprotocol/services#4950 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·