Skip to content

Commit 778d4f0

Browse files
committed
Fix: sz::lookup examples in Rs
1 parent 42270c8 commit 778d4f0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

rust/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ pub mod sz {
468468
/// To convert uppercase ASCII characters to lowercase:
469469
///
470470
/// ```
471-
/// let mut to_lower = [0u8; 256];
471+
/// use stringzilla::sz;
472+
/// let mut to_lower: [u8; 256] = core::array::from_fn(|i| i as u8);
472473
/// for (upper, lower) in ('A'..='Z').zip('a'..='z') {
473474
/// to_lower[upper as usize] = lower as u8;
474475
/// }
@@ -508,16 +509,16 @@ pub mod sz {
508509
///
509510
/// ```
510511
/// use stringzilla::sz;
511-
/// let mut to_lower = [0u8; 256];
512+
/// let mut to_lower: [u8; 256] = core::array::from_fn(|i| i as u8);
512513
/// for (upper, lower) in ('A'..='Z').zip('a'..='z') {
513514
/// to_lower[upper as usize] = lower as u8;
514515
/// }
515-
/// let mut text = b"HELLO WORLD!";
516+
/// let mut text = *b"HELLO WORLD!";
516517
/// sz::lookup_inplace(&mut text, to_lower);
517-
/// assert_eq!(text, "hello world!");
518+
/// assert_eq!(text, *b"hello world!");
518519
/// ```
519520
///
520-
pub fn lookup_inplace<T>(buffer: &T, table: [u8; 256])
521+
pub fn lookup_inplace<T>(buffer: &mut T, table: [u8; 256])
521522
where
522523
T: AsMut<[u8]> + ?Sized,
523524
{

0 commit comments

Comments
 (0)