Skip to content

<String as der::Encode>::to_vec can result in ambiguous code #724

@Nemo157

Description

@Nemo157

If you have Encode imported in a module for other uses it could be easy to mess up .to_vec() vs .into_bytes().

use der::Encode;

fn main() {
    assert_eq!("foo".to_string().into_bytes(), "foo".to_string().to_vec().unwrap());
}
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `[102, 111, 111]`,
 right: `[12, 3, 102, 111, 111]`', src/main.rs:4:5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions