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

Idea: RangeFrom #15

Closed
CAD97 opened this issue Mar 13, 2020 · 4 comments
Closed

Idea: RangeFrom #15

CAD97 opened this issue Mar 13, 2020 · 4 comments

Comments

@CAD97
Copy link
Collaborator

CAD97 commented Mar 13, 2020

If we reserve u32::MAX to mean unbounded, we can have TextRange::from(size) => size.. and TextRange::to(size) => 0..size. (The lower unbound can just be immediately normalized to 0.)

@CAD97 CAD97 mentioned this issue Mar 13, 2020
@matklad
Copy link
Member

matklad commented Mar 13, 2020

TextRange::from(size)

This is objectively horrible, because it's not From::from :)

@CAD97
Copy link
Collaborator Author

CAD97 commented Mar 13, 2020

yeah I realize that now but ignore the naming is the underlying concept good/bad/meh/worth-it/not

@matklad
Copy link
Member

matklad commented Mar 13, 2020

Another problem with treating u32 as unbounded is that it adds semi-infitite ranges. And that makes usages of TextRange harder: even len then should return an Option<TextSize>.

@CAD97
Copy link
Collaborator Author

CAD97 commented Mar 13, 2020

Still, one of the main uses of the TextUnit->usize escape hatch in ra is RangeFrom... if only we could let string[TextSize..] work... SliceIndex is actually stable, it's just sealed. I asked about it, but obviously an implementable SliceIndex is a while away even if desirable.

CAD97 added a commit to CAD97/text_unit that referenced this issue Mar 13, 2020
CAD97 added a commit to CAD97/text_unit that referenced this issue Mar 13, 2020
CAD97 added a commit to CAD97/text_unit that referenced this issue Mar 13, 2020
@CAD97 CAD97 linked a pull request Mar 14, 2020 that will close this issue
@CAD97 CAD97 removed a link to a pull request Mar 19, 2020
@CAD97 CAD97 closed this as completed Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants