Skip to content

Commit

Permalink
feat(storey): return ix on Column::push
Browse files Browse the repository at this point in the history
  • Loading branch information
uint committed May 8, 2024
1 parent 43f68fa commit d9c1976
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/storey/src/containers/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ where
/// access.push(&1337).unwrap();
/// access.push(&42).unwrap();
/// ```
pub fn push(&mut self, value: &T) -> Result<(), PushError<E::EncodeError>> {
pub fn push(&mut self, value: &T) -> Result<u32, PushError<E::EncodeError>> {
let bytes = value.encode()?;

let ix = match self
Expand All @@ -292,7 +292,7 @@ where
.unwrap_or(0);
self.storage.set_meta(META_LEN, &(len + 1).to_be_bytes());

Ok(())
Ok(ix)
}

/// Update the value associated with the given key.
Expand Down Expand Up @@ -413,8 +413,8 @@ mod tests {
let column = Column::<u64, TestEncoding>::new(0);
let mut access = column.access(&mut storage);

access.push(&1337).unwrap();
access.push(&42).unwrap();
assert_eq!(access.push(&1337).unwrap(), 0);
assert_eq!(access.push(&42).unwrap(), 1);

assert_eq!(access.get(0).unwrap(), Some(1337));
assert_eq!(access.get(1).unwrap(), Some(42));
Expand Down

0 comments on commit d9c1976

Please sign in to comment.