11//! Keycode is a lexicographical order-preserving binary encoding for use with
2- //! keys. It is designed for simplicity, not efficiency (i.e. it does not use
3- //! varints or other compression methods).
2+ //! keys in key/value stores . It is designed for simplicity, not efficiency
3+ //! (i.e. it does not use varints or other compression methods).
44//!
55//! Ordering is important because it allows limited scans across specific parts
66//! of the keyspace, e.g. scanning an individual table or using an index range
@@ -56,9 +56,8 @@ use crate::error::{Error, Result};
5656/// keep it simple.
5757pub fn serialize < T : Serialize > ( key : & T ) -> Vec < u8 > {
5858 let mut serializer = Serializer { output : Vec :: new ( ) } ;
59- // Panic on serialization failures, as this is typically an issue with the
60- // provided data structure.
61- key. serialize ( & mut serializer) . expect ( "keycode serialization failed" ) ;
59+ // Panic on failure, as this is a problem with the data structure.
60+ key. serialize ( & mut serializer) . expect ( "key must be serializable" ) ;
6261 serializer. output
6362}
6463
@@ -84,7 +83,7 @@ pub fn deserialize<'a, T: Deserialize<'a>>(input: &'a [u8]) -> Result<T> {
8483/// prefixes after it.
8584pub fn prefix_range ( prefix : & [ u8 ] ) -> ( Bound < Vec < u8 > > , Bound < Vec < u8 > > ) {
8685 let start = Bound :: Included ( prefix. to_vec ( ) ) ;
87- let end = match prefix. iter ( ) . rposition ( |b| * b != 0xff ) {
86+ let end = match prefix. iter ( ) . rposition ( |& b| b != 0xff ) {
8887 Some ( i) => Bound :: Excluded (
8988 prefix. iter ( ) . take ( i) . copied ( ) . chain ( std:: iter:: once ( prefix[ i] + 1 ) ) . collect ( ) ,
9089 ) ,
0 commit comments