Sha256: c25987ea6d9a7dde74d58a49c332d223da3a495569cb79e3fe921bce51729ead

Contents?: true

Size: 732 Bytes

Versions: 38

Compression:

Stored size: 732 Bytes

Contents

use nom::bytes::complete::escaped;
use nom::character::complete::digit1;
use nom::character::complete::one_of;
use nom::{error::ErrorKind, Err, IResult};

fn esc(s: &str) -> IResult<&str, &str, (&str, ErrorKind)> {
  escaped(digit1, '\\', one_of("\"n\\"))(s)
}

#[cfg(feature = "alloc")]
fn esc_trans(s: &str) -> IResult<&str, String, (&str, ErrorKind)> {
  use nom::bytes::complete::{escaped_transform, tag};
  escaped_transform(digit1, '\\', tag("n"))(s)
}

#[test]
fn test_escaped() {
  assert_eq!(esc("abcd"), Err(Err::Error(("abcd", ErrorKind::Escaped))));
}

#[test]
#[cfg(feature = "alloc")]
fn test_escaped_transform() {
  assert_eq!(
    esc_trans("abcd"),
    Err(Err::Error(("abcd", ErrorKind::EscapedTransform)))
  );
}

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-28.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-27.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-26.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-25.0.2 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-25.0.1 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-25.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-24.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-23.0.2 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-22.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-21.0.1 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-20.0.2 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-20.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-18.0.3 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-17.0.1 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-17.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-16.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-15.0.1 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-15.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-14.0.4 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs