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-14.0.3 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-14.0.1 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-14.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-13.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-12.0.1 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-12.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-11.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-10.0.1 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-10.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-9.0.4 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-9.0.1 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-8.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-7.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-6.0.1 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-6.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-5.0.0 ./ext/cargo-vendor/nom-7.1.3/tests/escaped.rs
wasmtime-0.4.1 ./ext/cargo-vendor/nom-7.1.1/tests/escaped.rs
wasmtime-0.4.0 ./ext/cargo-vendor/nom-7.1.1/tests/escaped.rs