fastxfix

Crates.iofastxfix
lib.rsfastxfix
version0.3.0
created_at2025-04-24 17:44:07.952714+00
updated_at2025-08-14 00:23:59.728718+00
descriptionExtremely fast prefix/suffix finder for any 2D data type
homepage
repositoryhttps://github.com/silverstillisntgold/fastxfix
max_upload_size
id1647573
size30,947
(silverstillisntgold)

documentation

https://docs.rs/fastxfix

README

FastXFix

A small utility crate for finding the longest common prefix/suffix of 2D collections at absolutely insane speeds, made possible by rayon and SIMD optimizations.

"2D collections" refers to arrangements like Vec<T>, HashSet<T>, or LinkedList<T>. When T implements AsRef<str>, you'll be able to use the methods of CommonStr on it. When T implements AsRef<&[U]> (meaning that T is a slice of some kind) then you'll have access to the methods of CommonRaw. These two conditions are not mutually exclusive, so it's up to the user to ensure they're using the method that best coincides with what they're trying to accomplish.

If you're trying to extract information about strings, always prefer using CommonStr methods: they are specifically optimized for handling rust's UTF-8 encoded strings.

Examples

use fastxfix::CommonStr;

let s1 = "wowie_this_is_a_string".to_string();
let s2 = "wowie_this_is_another_string_".to_string();

let v = vec![s1, s2];
let common_prefix = v.common_prefix().expect("we know there is a common prefix");
let len = v.common_prefix_len().expect("we know there is a common prefix");
assert!(common_prefix.len() == len.get());
// The strings have no common suffix.
assert!(v.common_suffix_len() == None);
Commit count: 37

cargo fmt