Skip to content

Provide Map[String]::get_from_string(Self, StringView) and Bytes #2874

@bobzhang

Description

@bobzhang
/// The `view` function and the `Hash` implementation of `View` should satisfy:
/// ```
/// view(key).hash() == key.hash() 
/// ```
fn get_by_view[K, View : Hash + Eq, Value](
  self : Self[K, Value],
  key : View,
  view~ : (K) -> View
) -> Value?

It is hard to reason about if the variant is met or not. for String, we added an optimization that "abc"[:].to_string() does not allocate, maybe we can add a special function:

Map[String]::get_from_string(self : Self, StringView)
Map[Bytes]::get_from_bytes(self : Self, BytesView)

Originally posted by @bobzhang in #2082 (comment)

Metadata

Metadata

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