1 unstable release
0.1.0 | Dec 27, 2022 |
---|
#27 in #intern
66 downloads per month
26KB
485 lines
symboltable
lib.rs
:
This crate offers a [SymbolTable] type which can store strings as lightweight [Symbols], which enable extremely fast comparison and total order operations. Depending on the backing data structure, the [SymbolTable] may also offer fast convertion from [Symbol] to [String]. Finally, [Symbol] is parameterized by a type, allowing you to intern strings coming from incomparable sources without the possibility of mixing them up. For example, if you intern an Address: Into and Username: Into, you can get back a Symbol
and a Symbol. These two [Symbol] types will share the same store and any benefits of compression, while ensuring you don't mix up one Symbol for another, as is easy with strings: ```text fn foo(address: String, username: String); foo(my_username, my_address); // This is well-typed, but is logically erronious, because the parameters were mixed up. fn foo2(address: Symbol, username: Symbol); // This formulation would produce an type error when you accidently // swap the argument positions.
Dependencies
~4–16MB
~162K SLoC