Skip to content

from_utf8 should take BytesContainer #17375

Closed
@mahkoh

Description

@mahkoh

std::str::from_utf8 takes &[u8] which means that you can't create a string from a &[c_char] in general.

Instead, from_utf8 should look like this:

pub fn from_utf8<T: BytesContainer>(v: &T) -> Option<&str>

Then implement BytesContainer for &[i8].

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