Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newtype for str / String #39

Open
sergiimk opened this issue Jul 9, 2020 · 0 comments
Open

Newtype for str / String #39

sergiimk opened this issue Jul 9, 2020 · 0 comments

Comments

@sergiimk
Copy link

sergiimk commented Jul 9, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant