pub struct Unsigned;Expand description
Determine if a char is a valid identifier for a parser and/or lexer according to
Unicode Standard Annex #31 rules.
use comprez::Unsigned;
fn main() {
let num = 1234u32;
let compressed = Unsigned::compress_61_439(num).unwrap();
let decompressed = Unsigned::decompress_61_439(compressed.to_vec()).unwrap();
println!("size before compression: {}", num.to_be_bytes().len());
//size before compression: 4
println!("size after compression: {}", compressed.len());
//size after compression: 2
println!("{}", decompressed == num);
//true
}features
unicode-xid supports a no_std feature. This eliminates dependence
on std, and instead uses equivalent functions from core.
unsigned only compression
Implementations
sourceimpl Unsigned
impl Unsigned
pub fn compress_478_even(num: u32) -> Result<[u8; 1], CompressError>
pub fn compress_122_878_even(num: u32) -> Result<[u8; 2], CompressError>
pub fn compress_61_439(num: u32) -> Result<[u8; 2], CompressError>
pub fn compress_31_457_278_even(num: u64) -> Result<[u8; 3], CompressError>
pub fn compress_15_728_639(num: u64) -> Result<[u8; 3], CompressError>
pub fn compress_8_053_063_678_even(num: u64) -> Result<[u8; 4], CompressError>
pub fn compress_4_026_531_839(num: u64) -> Result<[u8; 4], CompressError>
sourceimpl Unsigned
impl Unsigned
pub fn decompress_478_even(bytes: Vec<u8>) -> Result<u32, DecompressError>
pub fn decompress_122_878_even(bytes: Vec<u8>) -> Result<u32, DecompressError>
pub fn decompress_61_439(bytes: Vec<u8>) -> Result<u32, DecompressError>
pub fn decompress_31_457_278_even(
bytes: Vec<u8>
) -> Result<u64, DecompressError>
pub fn decompress_15_728_639(bytes: Vec<u8>) -> Result<u64, DecompressError>
pub fn decompress_8_053_063_678_even(
bytes: Vec<u8>
) -> Result<u64, DecompressError>
pub fn decompress_4_026_531_839(bytes: Vec<u8>) -> Result<u64, DecompressError>
Auto Trait Implementations
impl RefUnwindSafe for Unsigned
impl Send for Unsigned
impl Sync for Unsigned
impl Unpin for Unsigned
impl UnwindSafe for Unsigned
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more