Skip to content

Newtype for str / String #39

@sergiimk

Description

@sergiimk

Have you ever considered supporting newtype derivations for string-backed identifiers?

I'm thinking of a similar reference-buffer duality as one between std::path::Path and PathBuf that gives you an option to wrap a str with the newtype without allocating, e.g.:

struct DatasetID(str);
struct DatasetIDBuf(String);

While some of the existing derivations are compatible with these types it still leaves a large enough amount of boilerplate to be written to enable conversions and comparisons between the two to discourage the use of the newtype pattern for string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions