Skip to main content

ferroui_base/utilities/
value_span.rs

1/// Pairing of value and positions sharing that value.
2#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3pub struct ValueSpan<T> {
4    start: i32,
5    length: i32,
6    value: T,
7}
8
9impl<T> ValueSpan<T> {
10    pub const fn new(start: i32, length: i32, value: T) -> Self {
11        Self { start, length, value }
12    }
13
14    /// Gets the start of the span.
15    #[inline]
16    pub const fn start(&self) -> i32 {
17        self.start
18    }
19
20    /// Gets the length of the span.
21    #[inline]
22    pub const fn length(&self) -> i32 {
23        self.length
24    }
25
26    /// Gets the value of the span.
27    #[inline]
28    pub const fn value(&self) -> &T {
29        &self.value
30    }
31}