y-ack / e

2 stars 1 forks source link

Fix potential crash if span is not contiguous in memory #9

Closed niconii closed 3 years ago

niconii commented 3 years ago

RopeSlice::as_str() can fail if the slice isn't contiguous in memory, so calling .unwrap() would crash the program. However, it isn't necessary to call as_str() in the first place, because Span::raw takes any type that can be converted to Cow<'a, str>, and RopeSlice is one of those types.

write_token's signature is also changed to compensate.