Implement typed RLV protocol parser (#78)
Some checks failed
Native code generation / deterministic (push) Failing after 2m0s
Imaging and meshing gate / native (push) Failing after 4m11s
JPEG 2000 feature / linux (push) Successful in 2m52s
Native Rust workspace compile / compile (push) Failing after 6m15s
Skia feature / linux (push) Has been cancelled
Some checks failed
Native code generation / deterministic (push) Failing after 2m0s
Imaging and meshing gate / native (push) Failing after 4m11s
JPEG 2000 feature / linux (push) Successful in 2m52s
Native Rust workspace compile / compile (push) Failing after 6m15s
Skia feature / linux (push) Has been cancelled
This commit is contained in:
@@ -1153,7 +1153,64 @@ impl<T> Future for AsyncEnumerableNext<T> {
|
||||
|
||||
pub struct ImmutableDictionary<TKey, TValue>(pub PhantomData<fn(TKey, TValue)>);
|
||||
|
||||
pub struct ImmutableList<T>(pub PhantomData<fn(T)>);
|
||||
/// Read-only, cheaply clonable snapshot corresponding to
|
||||
/// `System.Collections.Immutable.ImmutableList<T>`.
|
||||
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq)]
|
||||
pub struct ImmutableList<T>(Arc<[T]>);
|
||||
|
||||
impl<T> ImmutableList<T> {
|
||||
/// Creates an immutable snapshot from owned values.
|
||||
#[must_use]
|
||||
pub fn from_vec(values: Vec<T>) -> Self {
|
||||
Self(values.into())
|
||||
}
|
||||
|
||||
/// Returns the snapshot as a slice.
|
||||
#[must_use]
|
||||
pub fn as_slice(&self) -> &[T] {
|
||||
&self.0
|
||||
}
|
||||
|
||||
/// Returns the number of values in the snapshot.
|
||||
#[must_use]
|
||||
pub fn len(&self) -> usize {
|
||||
self.0.len()
|
||||
}
|
||||
|
||||
/// Returns whether the snapshot contains no values.
|
||||
#[must_use]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.0.is_empty()
|
||||
}
|
||||
|
||||
/// Iterates over the snapshot.
|
||||
pub fn iter(&self) -> std::slice::Iter<'_, T> {
|
||||
self.0.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<Vec<T>> for ImmutableList<T> {
|
||||
fn from(values: Vec<T>) -> Self {
|
||||
Self::from_vec(values)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> std::ops::Deref for ImmutableList<T> {
|
||||
type Target = [T];
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> IntoIterator for &'a ImmutableList<T> {
|
||||
type Item = &'a T;
|
||||
type IntoIter = std::slice::Iter<'a, T>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.iter()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ICollection;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user