mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
docs(codegen): fix example for CodeBuffer::print_ascii_bytes (#6535)
Fix example and add a test.
This commit is contained in:
parent
77f3a1a9dd
commit
7e909a7e6c
1 changed files with 12 additions and 1 deletions
|
|
@ -320,7 +320,7 @@ impl CodeBuffer {
|
||||||
/// use oxc_codegen::CodeBuffer;
|
/// use oxc_codegen::CodeBuffer;
|
||||||
/// let mut code = CodeBuffer::new();
|
/// let mut code = CodeBuffer::new();
|
||||||
///
|
///
|
||||||
/// code.print_ascii([b'f', b'o', b'o'].into_iter());
|
/// code.print_ascii_bytes([b'f', b'o', b'o']);
|
||||||
/// assert_eq!(String::from(code), "foo");
|
/// assert_eq!(String::from(code), "foo");
|
||||||
/// ```
|
/// ```
|
||||||
pub fn print_ascii_bytes<I>(&mut self, bytes: I)
|
pub fn print_ascii_bytes<I>(&mut self, bytes: I)
|
||||||
|
|
@ -497,6 +497,17 @@ mod test {
|
||||||
assert_eq!(String::from(code), "foo");
|
assert_eq!(String::from(code), "foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[allow(clippy::byte_char_slices)]
|
||||||
|
fn print_ascii_bytes() {
|
||||||
|
let mut code = CodeBuffer::new();
|
||||||
|
code.print_ascii_bytes([b'f', b'o', b'o']);
|
||||||
|
|
||||||
|
assert_eq!(code.len(), 3);
|
||||||
|
assert_eq!(code.as_bytes(), &[b'f', b'o', b'o']);
|
||||||
|
assert_eq!(String::from(code), "foo");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn peek_nth_char_back() {
|
fn peek_nth_char_back() {
|
||||||
let mut code = CodeBuffer::new();
|
let mut code = CodeBuffer::new();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue