Skip to content

Commit

Permalink
fix data mut
Browse files Browse the repository at this point in the history
  • Loading branch information
tickbh committed Sep 14, 2024
1 parent d28ccb9 commit 8bf9ae0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["algorithm-macro"]

[package]
name = "algorithm"
version = "0.1.10"
version = "0.1.11"
edition = "2021"
authors = ["tickbh <[email protected]>"]
description = "about algorithm data structure, now has ttl with lru/lru-k/lfu/arc and slab/rbtree/roaring_bitmap/timer_wheelss, 关于算法常用的数据结构"
Expand Down
15 changes: 13 additions & 2 deletions src/buf/binary_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,20 @@ impl BinaryMut {
}
}

/// 获取可读且已初始化的数据
///
/// # Examples
///
/// ```
/// use algorithm::buf::{BinaryMut, Bt, BtMut};
///
/// let mut buf = BinaryMut::with_capacity(0);
/// assert!(buf.data_mut().len() != 0);
///
/// ```
pub fn data_mut(&mut self) -> &mut [u8] {
if self.wpos + 128 < self.vec.capacity() {
self.reserve(128);
if self.wpos + 128 > self.vec.len() {
self.vec.resize(self.wpos + 128, 0);
}
&mut self.vec[self.wpos..]
}
Expand Down

0 comments on commit 8bf9ae0

Please sign in to comment.