We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
new
1 parent 5a3c94a commit 6d8a512Copy full SHA for 6d8a512
1 file changed
sponge-cursor/src/lib.rs
@@ -37,6 +37,21 @@ impl<Rate: ArraySize> Default for SpongeCursor<Rate> {
37
}
38
39
impl<Rate: ArraySize> SpongeCursor<Rate> {
40
+ /// Create new cursor with the provided position.
41
+ ///
42
+ /// Returns `None` if `pos` is bigger or equal to `Rate`.
43
+ #[must_use]
44
+ pub fn new(pos: u8) -> Option<Self> {
45
+ if usize::from(pos) < Rate::USIZE {
46
+ Some(Self {
47
+ pos,
48
+ _pd: PhantomData,
49
+ })
50
+ } else {
51
+ None
52
+ }
53
54
+
55
/// Absorb bytes from `data` into a `u64`-based state using little ednian byte order.
56
///
57
/// Size of state MUST be greater or equal to `Rate`. Using an invalid `N` will result in
0 commit comments