Skip to content

ExtendInto<Extender=Vec<u8>> appears to have no useful implementors #1206

@ExpHP

Description

@ExpHP

It is unclear to me how to use bytes::complete::escape_transform on bytestrings, because the only implementors of ExtendInto<Extender=Vec<u8>> are [u8] and &[u8], neither of which can be returned without borrowing from the input.

  • Rust version : rustc 1.46.0
  • nom version : 5.0.0
  • nom compilation features used:

Test case

use nom::{
    bytes::complete::{escaped_transform, take, is_not},
    combinator::{map},
};

fn main() {
    let res: nom::IResult<_, _> = escaped_transform(  // Error: ExtendInto is not implemented for u8
        is_not(r#"\""#),
        '\\',
        map(take(1u32), |bytes: &[u8]| match bytes[0] {
            b'n' => b'\n',
            b => b,
        }),
    )(b"sfj\\n\\isoeg");
    assert_eq!(res, Ok((&b""[..], b"sfj\nisoeg".to_vec())))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions