pub fn prev_key(key: &[u8]) -> Vec<u8> ⓘ
Expand description
Computes the previous key of the given key.
If the key has no predecessor key (e.g. the input is “\x00\x00”), the result would be a “\xff\xff” vector.
§Examples
use risingwave_hummock_sdk::key::prev_key;
assert_eq!(prev_key(b"123"), b"122");
assert_eq!(prev_key(b"12\x00"), b"11\xff");
assert_eq!(prev_key(b"\x00\x00"), b"\xff\xff");
assert_eq!(prev_key(b"\x00\x01"), b"\x00\x00");
assert_eq!(prev_key(b"T"), b"S");
assert_eq!(prev_key(b""), b"");