Skip to content

Commit

Permalink
improve Column API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
uint committed Oct 30, 2024
1 parent bd11f22 commit 729e083
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/storey/src/containers/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,23 @@ where
{
/// Append a new value to the end of the column.
///
/// Returns the key of the newly inserted value. If the column is empty, the first
/// key will be `1`.
///
/// # Example
/// ```
/// # use mocks::encoding::TestEncoding;
/// # use mocks::backend::TestStorage;
/// use storey::containers::Column;
///
/// const COLUMN_KEY: u8 = 0;
///
/// let mut storage = TestStorage::new();
/// let column = Column::<u64, TestEncoding>::new(0);
/// let column = Column::<u64, TestEncoding>::new(COLUMN_KEY);
/// let mut access = column.access(&mut storage);
///
/// access.push(&1337).unwrap();
/// access.push(&42).unwrap();
/// assert_eq!(access.push(&1337).unwrap(), 1);
/// assert_eq!(access.push(&42).unwrap(), 2);
/// ```
pub fn push(&mut self, value: &T) -> Result<u32, PushError<E::EncodeError>> {
let bytes = value.encode()?;
Expand Down

0 comments on commit 729e083

Please sign in to comment.