On Mon, Sep 30, 2024 at 1:16 AM Trevor Gross <[email protected]> wrote:
>
> On Fri, Sep 13, 2024 at 5:01 PM Alice Ryhl <[email protected]> wrote:
>
> > +//! Utilities for working with ranges of indices.
> > +
> > +/// A range of indices.
> > +///
> > +/// This utility is useful for ensuring that no index in the range is used 
> > more than once.
> > +#[derive(Debug)]
> > +pub struct Range {
> > +    offset: usize,
> > +    length: usize,
> > +}
>
> Would a name like "DataRange" or "CheckedRange" be better here, to
> avoid confusion with core::ops::Range?

Probably a good idea. I've had collisions on those types.

> > +    /// Use this range of indices.
> > +    ///
> > +    /// This destroys the `Range` object, so these indices cannot be used 
> > again after this call.
> > +    pub fn use_range(self) -> UsedRange {
>
> Maybe just `.use()`?

Makes sense to me.

> > +    /// Assert that this range is aligned properly.
> > +    pub fn assert_aligned(&self, alignment: usize) -> Result<(), 
> > RangeError> {
>
> It would probably be good to warn that this alignment is relative to
> the offset, i.e. if you split a range at an unaligned point then this
> may not be useful.
>
> This is a pretty cool API idea.

Thanks!

Alice

Reply via email to