Crates.io | fastxfix |
lib.rs | fastxfix |
version | 0.3.0 |
created_at | 2025-04-24 17:44:07.952714+00 |
updated_at | 2025-08-14 00:23:59.728718+00 |
description | Extremely fast prefix/suffix finder for any 2D data type |
homepage | |
repository | https://github.com/silverstillisntgold/fastxfix |
max_upload_size | |
id | 1647573 |
size | 30,947 |
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.
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);