1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/// In-place translation of a C-style NUL-terminated string, replacing all occurrences of one byte with another.
///
/// This function mutates the given pointer to a NUL-terminated string (`*mut i8`), replacing every occurrence
/// of the byte `from` with the byte `to`. The operation stops at the first NUL byte (`\0`).
///
/// # Safety
///
/// - The pointer `s` must be valid and point to a mutable, NUL-terminated string.
/// - The memory must be writable and large enough to contain the string and the NUL terminator.
/// - Behavior is undefined if `s` is not properly NUL-terminated or is invalid.
///
/// # Arguments
///
/// * `s` - Pointer to the mutable NUL-terminated string.
/// * `from` - The byte value to replace.
/// * `to` - The byte value to substitute.
///
/// # Examples
///
/// ```
/// use text_fx::transform::tr;
///
/// let mut buf = *b"hello\0";
/// tr(buf.as_mut_ptr() as *mut _, b'l' as i8, b'p' as i8);
/// assert_eq!(buf, *b"heppo\0");
/// ```