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

Replace Loc with Range<u32> #10

Open
rljacobson opened this issue Oct 1, 2022 · 0 comments
Open

Replace Loc with Range<u32> #10

rljacobson opened this issue Oct 1, 2022 · 0 comments

Comments

@rljacobson
Copy link

rljacobson commented Oct 1, 2022

By changing Loc to be

pub struct Loc {
	start: u32,  // changed "begin" to "start"
	end: u32
}

you can actually swap out Loc altogether for Range<u32>. To avoid confusing situations when using Range<u32> as an iterator, Range<u32> does not implement Copy, so you will need to add .clone() in a few places. (The calls to clone are really just copies anyway, except requiring a call to clone makes it more explicit that a new Range<u32> is being created.)

If client code wants to use its own custom location type, they came implement From<CustomLocType> for Range<u32> or have a to_range() method or something.

I can make a PR if you'd like.

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