Skip to main content

prefix_end

Function prefix_end 

Source
pub fn prefix_end(prefix: impl AsRef<[u8]>) -> Option<Vec<u8>>
Expand description

Return the smallest exclusive upper bound for all keys with prefix.

Returns None when the prefix covers the rest of the keyspace, which is true for the empty prefix and for prefixes made entirely of 0xff bytes.

ยงExample

use prolly::prefix_end;

assert_eq!(prefix_end(b"user/42/"), Some(b"user/420".to_vec()));
assert_eq!(prefix_end(b""), None);