Skip to content

Commit

Permalink
value -> take_value
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Dec 1, 2023
1 parent eeb3cbe commit 7017868
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions experimental/zerotrie/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ where
/// // Get out the value for "abc"
/// let mut cursor = trie.cursor();
/// write!(&mut cursor, "abc");
/// assert_eq!(cursor.value(), Some(0));
/// assert_eq!(cursor.take_value(), Some(0));
/// ```
///
/// Find the longest prefix match:
Expand All @@ -52,7 +52,7 @@ where
/// if cursor.is_empty() {
/// break;
/// }
/// if cursor.value().is_some() {
/// if cursor.take_value().is_some() {
/// longest_prefix = i;
/// }
/// cursor.step(*b);
Expand Down Expand Up @@ -102,21 +102,21 @@ impl<'a> ZeroTrieSimpleAsciiCursor<'a> {
///
/// // Search the trie for the string "abcdxy"
/// let mut cursor = trie.cursor();
/// assert_eq!(cursor.value(), None); // ""
/// assert_eq!(cursor.take_value(), None); // ""
/// cursor.step(b'a');
/// assert_eq!(cursor.value(), None); // "a"
/// assert_eq!(cursor.take_value(), None); // "a"
/// cursor.step(b'b');
/// assert_eq!(cursor.value(), None); // "ab"
/// assert_eq!(cursor.take_value(), None); // "ab"
/// cursor.step(b'c');
/// assert_eq!(cursor.value(), Some(0)); // "abc"
/// assert_eq!(cursor.take_value(), Some(0)); // "abc"
/// cursor.step(b'd');
/// assert_eq!(cursor.value(), None); // "abcd"
/// assert_eq!(cursor.take_value(), None); // "abcd"
/// assert!(!cursor.is_empty());
/// cursor.step(b'x'); // no strings have the prefix "abcdx"
/// assert!(cursor.is_empty());
/// assert_eq!(cursor.value(), None); // "abcdx"
/// assert_eq!(cursor.take_value(), None); // "abcdx"
/// cursor.step(b'y');
/// assert_eq!(cursor.value(), None); // "abcdxy"
/// assert_eq!(cursor.take_value(), None); // "abcdxy"
/// ```
#[inline]
pub fn step(&mut self, byte: u8) {
Expand All @@ -138,11 +138,11 @@ impl<'a> ZeroTrieSimpleAsciiCursor<'a> {
///
/// assert_eq!(Some(0), trie.get(""));
/// let mut cursor = trie.cursor();
/// assert_eq!(Some(0), cursor.value());
/// assert_eq!(None, cursor.value());
/// assert_eq!(Some(0), cursor.take_value());
/// assert_eq!(None, cursor.take_value());
/// ```
#[inline]
pub fn value(&mut self) -> Option<usize> {
pub fn take_value(&mut self) -> Option<usize> {
take_value(&mut self.trie.store)
}

Expand Down
2 changes: 1 addition & 1 deletion provider/blob/src/blob_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl<'data> BlobSchemaV2<'data> {
#[allow(clippy::unwrap_used)] // DataLocale::write_to produces ASCII only
req.locale.write_to(&mut cursor).unwrap();
let blob_index = cursor
.value()
.take_value()
.ok_or_else(|| DataErrorKind::MissingLocale.with_req(key, req))?;
let buffer = self
.buffers
Expand Down

0 comments on commit 7017868

Please sign in to comment.