icu4x
icu4x copied to clipboard
Additional ZeroMap2d and ZeroMapKV cleanup
Cleanup from comments in PRs #1876 and #1901:
- [x] Figure out
'staticbound on the const constructor forBorrowedVarianthttps://github.com/unicode-org/icu4x/pull/1901#discussion_r876405607 - [x] Add
SlicetoZeroMapKVhttps://github.com/unicode-org/icu4x/pull/1901#discussion_r876406165 - [x] Rename
BorrowedVarianttoSliceVarianthttps://github.com/unicode-org/icu4x/pull/1901#discussion_r876406310 - [x] Remove the trait
BorrowedZeroVecLikehttps://github.com/unicode-org/icu4x/pull/1901#discussion_r876406813 - [ ] Remove the
.get()and.get_copied()methods ofZeroMap2d, removeKeyError, change the cursor methods to have those names, and update call sites https://github.com/unicode-org/icu4x/pull/1876#issuecomment-1123711791 - [ ] ~Consider removing
zvl_binary_searchandzvl_binary_search_in_rangeand rely on only the predicate-based versions of them~ (No, because it's theoretically possible that the non-predicate versions could be faster) - [x] Fix typo: https://github.com/unicode-org/icu4x/pull/1876#discussion_r889060576
I ended up leaving the 'static bound for SliceVariant where it is, on the methods that need to call zvl_new_borrowed, because putting it on the associated type itself requires T: 'static due to https://github.com/rust-lang/rust/issues/92094, even though it shouldn't, since T::ULE is the thing that needs to be 'static.
@robertbastian I kind-of like having an all-in-one ZeroMap2d::get(k0, k1). How strongly do you feel about getting rid of that method and keeping the cursor methods named get0 and get1? If we keep the all-in-one get, I may make it return an Option since KeyError is no longer necessary.
I think get0 and get1 are more important APIs as they allow more client flexibility and force separate error handling, so I'd like them to have the standard names (standard as in a nested HashMap).
map.get(k0).and_then(|m| m.get(k1)) isn't too verbose if you really don't care where the None comes from.
ok, here's what I will do then:
- Rename
getandget_copiedtoget_2dandget_copied_2d - Rename
get0anditer0togetanditer - Rename
get1,iter1, andget1_copiedtoget,iter, andget_copied
Works for me
I realized that this is a Utilities 1.0 issue, not an ICU4X 1.0 issue. I did half of the work in #2279 and I will do the other half at a later time.