iliabylich/rust-bison-skeleton

Replace `Loc` with `Range<u32>`

Opened this issue · 0 comments

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.