o3 0.62.0

shared-nothing primitives
Documentation
use std::{marker, ops};

use crate::buffer::bytes::scope;

/// Bounds selected from the immutable owner with this invariant identity.
#[derive(Debug)]
pub struct Range<'id> {
    pub(in crate::buffer::bytes::scope) bounds: ops::Range<usize>,
    pub(in crate::buffer::bytes::scope) brand: marker::PhantomData<*mut &'id ()>,
}

impl<'id> Range<'id> {
    pub(in crate::buffer::bytes::scope) fn new(
        source: scope::View<'_, 'id>,
        bounds: ops::Range<usize>,
    ) -> Self {
        Self {
            bounds,
            brand: source.brand,
        }
    }
}

impl Range<'_> {
    pub(in crate::buffer) fn into_inner(self) -> ops::Range<usize> {
        self.bounds
    }

    pub fn is_empty(&self) -> bool {
        self.len() == 0
    }

    pub fn len(&self) -> usize {
        self.bounds.end - self.bounds.start
    }
}

const _: () = assert!(size_of::<Range<'static>>() == 2 * size_of::<usize>());