agram

Crates.ioagram
lib.rsagram
version1.0.1
sourcesrc
created_at2022-02-18 18:39:46.301246
updated_at2022-02-18 19:37:17.89098
descriptionAn offline anagram library
homepage
repositoryhttps://github.com/grantshandy/agram
max_upload_size
id534826
size4,871,131
Grant Handy (grantshandy)

documentation

https://docs.rs/agram

README

agram

An anagram library for Rust.

Add to your Cargo.toml:

agram = "1.0"

Basic example:

use std::env;

fn main() {
    let anagrams = agram::get(env::args().nth(1).expect("You must provide a word"));

    println!("count: {}", anagrams.count);
    for word in anagrams.words {
        println!("   {word}");
    }
}
$ cargo build --release --example basic
$ target/release/examples/basic thing
count: 1
   night

Runtime Decompression

The word list is compressed at build time, then decompressed using gzip at runtime. This saves us quite a bit of space in the binary with the drawback that your first request will take a little longer while the library decompresses the list into memory. You can make this faster by calling the init function in the library.

word list: 4.7M
example binary before compression: 8.1M
example binary after compression: 5.0M
Commit count: 0

cargo fmt