#alphabet #match #generate #proc-macro #base58 #dont #slow

macro match-lookup

proc macro for generating match block for alphabets, please dont use this. its slow and extremly likely to not be what you are looking for.

2 releases

0.1.1 Jul 14, 2022
0.1.0 Jul 4, 2022

#17 in #slow

Download history 44/week @ 2024-07-27 3/week @ 2024-08-03 3/week @ 2024-08-17 23/week @ 2024-08-24 5/week @ 2024-08-31 8/week @ 2024-09-14 79/week @ 2024-09-21 103/week @ 2024-09-28 90/week @ 2024-10-05 33/week @ 2024-10-12 37/week @ 2024-10-19 2/week @ 2024-10-26 5/week @ 2024-11-02

100 downloads per month
Used in 2 crates

MIT license

4KB
83 lines

A no_std centric implementation of base-x

This requires a nightly compiler to use the array API.

Features used under the 'unstable' flag:

  • const_fn_floating_point_arithmetic
  • generic_const_exprs

Implementing a new Alphabet is rather simple:

use smol_base_x::*;
pub struct Base58 {}

impl Base<58> for Base58 {
    const ALPHABET: [u8; 58] = *b"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
}

Implementing Base will automatically generate a 256 byte LUT, which was chosen over a match statement based off of benchmarks in benches/lut_vs_matches

this lib provides a macro under unstable for generating a match statement equivalent to a LUT, but is mostly useful for when dealing with non-ascii alphabets (which are currently unmaintained).

Dependencies

~1.5MB
~37K SLoC