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

Use references for &[T]s token type #590

Open
yyy33 opened this issue Aug 26, 2024 · 3 comments
Open

Use references for &[T]s token type #590

yyy33 opened this issue Aug 26, 2024 · 3 comments
Labels
A-input Area: input / parsing state M-breaking-change Meta: Implementing or merging this will introduce a breaking change.

Comments

@yyy33
Copy link

yyy33 commented Aug 26, 2024

Let users decide if they want to clone or not when they use it

where an &T is returned instead of a T:
code

@epage epage added M-breaking-change Meta: Implementing or merging this will introduce a breaking change. A-input Area: input / parsing state labels Aug 27, 2024
@epage
Copy link
Collaborator

epage commented Aug 27, 2024

Are you meaning to change type Token = T; to type Token = &T;?

If we did then that would first be a breaking change and require waiting until we feel its appropriate to make one.

Also, that signature I gave is incomplete. We'd need that to be type Token<'t> = &'t T. I've not dealt much with GATs, I'm unsure if we can do type Token<'static> = char in other cases. &str streams with a token of char is an example of where we can't use a reference.

It'd be good to experiment with this to see how feasible it is to do something like this before we get to 0.7

@yyy33
Copy link
Author

yyy33 commented Aug 27, 2024

Are you meaning to change type Token = T; to type Token = &T;?

yes

@epage epage changed the title Avoid cloning on stream's slicing implementation Use references for &[T]s token type Aug 27, 2024
@epage
Copy link
Collaborator

epage commented Sep 6, 2024

Also started #591 to discuss this and other needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-input Area: input / parsing state M-breaking-change Meta: Implementing or merging this will introduce a breaking change.
Projects
None yet
Development

No branches or pull requests

3 participants
@epage @yyy33 and others