Sign In

zerovec

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zerovec - cargo Package Compare versions

Package version was removed
This package version has been unpublished, mostly likely due to security reasons
Comparing version
0.11.2
to
0.11.3
+1
-1
.cargo_vcs_info.json
{
"git": {
"sha1": "5e404744dd6c9dd7f86aac82586e3fa98ea75f7f"
"sha1": "e46f9841b745b8148086b43daaf853692de26f67"
},
"path_in_vcs": "utils/zerovec"
}

@@ -900,3 +900,3 @@ # This file is automatically @generated by Cargo.

name = "zerovec"
version = "0.11.2"
version = "0.11.3"
dependencies = [

@@ -903,0 +903,0 @@ "bincode",

@@ -16,3 +16,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO

name = "zerovec"
version = "0.11.2"
version = "0.11.3"
authors = ["The ICU4X Project Developers"]

@@ -19,0 +19,0 @@ build = false

@@ -65,3 +65,3 @@ // This file is part of ICU4X. For terms of use, please see the file

/// * `key_hashes` - [`ExactSizeIterator`] over the hashed key values
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
#[expect(clippy::indexing_slicing, clippy::unwrap_used)]
pub fn compute_displacements(

@@ -68,0 +68,0 @@ key_hashes: impl ExactSizeIterator<Item = u64>,

@@ -74,7 +74,7 @@ // This file is part of ICU4X. For terms of use, please see the file

#[allow(clippy::unwrap_used)] // g is in-range
#[expect(clippy::unwrap_used)] // g is in-range
let (d0, d1) = self.displacements.get(g).unwrap();
let index = compute_index((f0, f1), (d0, d1), self.displacements.len() as u32)?;
#[allow(clippy::unwrap_used)] // index is in 0..self.keys.len()
#[expect(clippy::unwrap_used)] // index is in 0..self.keys.len()
let found = self.keys.zvl_get(index).unwrap();

@@ -140,5 +140,5 @@ if K::Container::zvl_get_as_t(found, |found| found == key.borrow()) {

(
#[allow(clippy::unwrap_used)] // index is in range
#[expect(clippy::unwrap_used)] // index is in range
self.keys.zvl_get(index).unwrap(),
#[allow(clippy::unwrap_used)] // index is in range
#[expect(clippy::unwrap_used)] // index is in range
self.values.zvl_get(index).unwrap(),

@@ -153,3 +153,3 @@ )

) -> impl ExactSizeIterator<Item = &'b <K as ZeroMapKV<'a>>::GetType> {
#[allow(clippy::unwrap_used)] // index is in range
#[expect(clippy::unwrap_used)] // index is in range
(0..self.len()).map(|index| self.keys.zvl_get(index).unwrap())

@@ -162,3 +162,3 @@ }

) -> impl ExactSizeIterator<Item = &'b <V as ZeroMapKV<'a>>::GetType> {
#[allow(clippy::unwrap_used)] // index is in range
#[expect(clippy::unwrap_used)] // index is in range
(0..self.len()).map(|index| self.values.zvl_get(index).unwrap())

@@ -165,0 +165,0 @@ }

@@ -122,2 +122,4 @@ // This file is part of ICU4X. For terms of use, please see the file

// TODO(#6588): Fix sensitivity to host endianness.
#[cfg(target_endian = "little")]
#[test]

@@ -136,2 +138,4 @@ fn test_serde_valid_deser_zhm() {

// TODO(#6588): Fix sensitivity to host endianness.
#[cfg(target_endian = "little")]
#[test]

@@ -138,0 +142,0 @@ fn test_bincode_zhm() {

@@ -225,3 +225,3 @@ // This file is part of ICU4X. For terms of use, please see the file

pub fn iter_keys(self) -> impl Iterator<Item = &'a <K as ZeroMapKV<'a>>::GetType> {
#[allow(clippy::unwrap_used)] // idx in 0..keys.zvl_len()
#[expect(clippy::unwrap_used)] // idx in 0..keys.zvl_len()
(0..self.keys.zvl_len()).map(move |idx| self.keys.zvl_get(idx).unwrap())

@@ -232,3 +232,3 @@ }

pub fn iter_values(self) -> impl Iterator<Item = &'a <V as ZeroMapKV<'a>>::GetType> {
#[allow(clippy::unwrap_used)] // idx in 0..keys.zvl_len() == values.zvl_len()
#[expect(clippy::unwrap_used)] // idx in 0..keys.zvl_len() == values.zvl_len()
(0..self.values.zvl_len()).map(move |idx| self.values.zvl_get(idx).unwrap())

@@ -262,5 +262,5 @@ }

(
#[allow(clippy::unwrap_used)] // idx in 0..keys.zvl_len()
#[expect(clippy::unwrap_used)] // idx in 0..keys.zvl_len()
self.keys.zvl_get(idx).unwrap(),
#[allow(clippy::unwrap_used)] // idx in 0..keys.zvl_len() = values.zvl_len()
#[expect(clippy::unwrap_used)] // idx in 0..keys.zvl_len() = values.zvl_len()
self.values.get(idx).unwrap(),

@@ -279,3 +279,2 @@ )

/// to `K::ULE` and `V::ULE`, in cases when `K` and `V` are fixed-size
#[allow(clippy::needless_lifetimes)] // Lifetime is necessary in impl Trait
pub fn iter_copied(self) -> impl Iterator<Item = (K, V)> + 'a {

@@ -285,5 +284,5 @@ let len = self.keys.zvl_len();

(
#[allow(clippy::unwrap_used)] // idx in 0..keys.zvl_len()
#[expect(clippy::unwrap_used)] // idx in 0..keys.zvl_len()
ZeroSlice::get(self.keys, idx).unwrap(),
#[allow(clippy::unwrap_used)] // idx in 0..keys.zvl_len() = values.zvl_len()
#[expect(clippy::unwrap_used)] // idx in 0..keys.zvl_len() = values.zvl_len()
ZeroSlice::get(self.values, idx).unwrap(),

@@ -290,0 +289,0 @@ )

@@ -6,2 +6,3 @@ // This file is part of ICU4X. For terms of use, please see the file

use super::vecs::{MutableZeroVecLike, ZeroVecLike};
use crate::ule::vartuple::VarTupleULE;
use crate::ule::*;

@@ -18,3 +19,2 @@ use crate::vecs::{VarZeroSlice, VarZeroVec};

// this lifetime should be a GAT on Container once that is possible
#[allow(clippy::upper_case_acronyms)] // KV is not an acronym
pub trait ZeroMapKV<'a> {

@@ -93,2 +93,13 @@ /// The container that can be used with this type: [`ZeroVec`] or [`VarZeroVec`].

impl<'a, A, B> ZeroMapKV<'a> for VarTupleULE<A, B>
where
A: AsULE + 'static,
B: VarULE + ?Sized,
{
type Container = VarZeroVec<'a, VarTupleULE<A, B>>;
type Slice = VarZeroSlice<VarTupleULE<A, B>>;
type GetType = VarTupleULE<A, B>;
type OwnedType = Box<VarTupleULE<A, B>>;
}
impl<'a> ZeroMapKV<'a> for str {

@@ -95,0 +106,0 @@ type Container = VarZeroVec<'a, str>;

@@ -299,5 +299,5 @@ // This file is part of ICU4X. For terms of use, please see the file

(
#[allow(clippy::unwrap_used)] // idx is in-range
#[expect(clippy::unwrap_used)] // idx is in-range
self.keys.zvl_get(idx).unwrap(),
#[allow(clippy::unwrap_used)] // idx is in-range
#[expect(clippy::unwrap_used)] // idx is in-range
self.values.zvl_get(idx).unwrap(),

@@ -312,3 +312,3 @@ )

) -> impl ExactSizeIterator<Item = &'b <K as ZeroMapKV<'a>>::GetType> {
#[allow(clippy::unwrap_used)] // idx is in-range
#[expect(clippy::unwrap_used)] // idx is in-range
(0..self.keys.zvl_len()).map(move |idx| self.keys.zvl_get(idx).unwrap())

@@ -321,3 +321,3 @@ }

) -> impl ExactSizeIterator<Item = &'b <V as ZeroMapKV<'a>>::GetType> {
#[allow(clippy::unwrap_used)] // idx is in-range
#[expect(clippy::unwrap_used)] // idx is in-range
(0..self.values.zvl_len()).map(move |idx| self.values.zvl_get(idx).unwrap())

@@ -452,3 +452,3 @@ }

Ok(index) => {
#[allow(clippy::unwrap_used)] // binary search
#[expect(clippy::unwrap_used)] // binary search
let ret = self.values.get(index).unwrap().to_boxed();

@@ -519,3 +519,3 @@ self.values.make_mut().replace(index, value);

V::Container::zvl_get_as_t(ule, |v| result.replace(*v));
#[allow(clippy::unwrap_used)] // `zvl_get_as_t` guarantees that the callback is invoked
#[expect(clippy::unwrap_used)] // `zvl_get_as_t` guarantees that the callback is invoked
Some(result.unwrap())

@@ -537,5 +537,5 @@ }

(
#[allow(clippy::unwrap_used)] // idx in 0..keys.zvl_len()
#[expect(clippy::unwrap_used)] // idx in 0..keys.zvl_len()
self.keys.zvl_get(idx).unwrap(),
#[allow(clippy::unwrap_used)] // idx in 0..keys.zvl_len() = values.zvl_len()
#[expect(clippy::unwrap_used)] // idx in 0..keys.zvl_len() = values.zvl_len()
ZeroSlice::get(&*self.values, idx).unwrap(),

@@ -554,3 +554,2 @@ )

/// to `K::ULE` and `V::ULE`, in cases when `K` and `V` are fixed-size
#[allow(clippy::needless_lifetimes)] // Lifetime is necessary in impl Trait
pub fn iter_copied<'b>(&'b self) -> impl Iterator<Item = (K, V)> + 'b {

@@ -561,5 +560,5 @@ let keys = &self.keys;

(
#[allow(clippy::unwrap_used)] // idx in 0..keys.zvl_len()
#[expect(clippy::unwrap_used)] // idx in 0..keys.zvl_len()
ZeroSlice::get(&**keys, idx).unwrap(),
#[allow(clippy::unwrap_used)] // idx in 0..keys.zvl_len() = values.zvl_len()
#[expect(clippy::unwrap_used)] // idx in 0..keys.zvl_len() = values.zvl_len()
ZeroSlice::get(&**values, idx).unwrap(),

@@ -566,0 +565,0 @@ )

@@ -9,3 +9,3 @@ // This file is part of ICU4X. For terms of use, please see the file

mod kv;
#[allow(clippy::module_inception)] // module is purely internal
#[expect(clippy::module_inception)] // module is purely internal
pub(crate) mod map;

@@ -12,0 +12,0 @@ mod vecs;

@@ -75,3 +75,3 @@ // This file is part of ICU4X. For terms of use, please see the file

{
#[allow(clippy::type_complexity)] // it's a marker type, complexity doesn't matter
#[expect(clippy::type_complexity)] // it's a marker type, complexity doesn't matter
marker: PhantomData<fn() -> (&'a K::OwnedType, &'a V::OwnedType)>,

@@ -78,0 +78,0 @@ }

@@ -77,3 +77,3 @@ // This file is part of ICU4X. For terms of use, please see the file

for i in 1..self.zvl_len() {
#[allow(clippy::unwrap_used)] // looping over the valid indices
#[expect(clippy::unwrap_used)] // looping over the valid indices
let curr = self.zvl_get(i).unwrap();

@@ -299,3 +299,3 @@ if Self::get_cmp_get(prev, curr) != Ordering::Less {

fn zvl_replace(&mut self, index: usize, value: &T) -> T {
#[allow(clippy::indexing_slicing)]
#[expect(clippy::indexing_slicing)]
let unaligned = self.with_mut(|vec| {

@@ -335,3 +335,3 @@ debug_assert!(index < vec.len());

#[allow(clippy::indexing_slicing)] // documented panic
#[expect(clippy::indexing_slicing)] // documented panic
fn zvl_permute(&mut self, permutation: &mut [usize]) {

@@ -473,3 +473,3 @@ assert_eq!(permutation.len(), self.zvl_len());

debug_assert!(index < vec.len());
#[allow(clippy::unwrap_used)]
#[expect(clippy::unwrap_used)]
let old = vec.get(index).unwrap().to_boxed();

@@ -482,3 +482,3 @@ vec.remove(index);

debug_assert!(index < vec.len());
#[allow(clippy::unwrap_used)]
#[expect(clippy::unwrap_used)]
let old = vec.get(index).unwrap().to_boxed();

@@ -521,3 +521,3 @@ vec.replace(index, value);

#[allow(clippy::unwrap_used)] // documented panic
#[expect(clippy::unwrap_used)] // documented panic
fn zvl_permute(&mut self, permutation: &mut [usize]) {

@@ -524,0 +524,0 @@ assert_eq!(permutation.len(), self.zvl_len());

@@ -91,3 +91,3 @@ // This file is part of ICU4X. For terms of use, please see the file

pub fn key0(&self) -> &'l K0::GetType {
#[allow(clippy::unwrap_used)] // safe by invariant on `self.key0_index`
#[expect(clippy::unwrap_used)] // safe by invariant on `self.key0_index`
self.keys0.zvl_get(self.key0_index).unwrap()

@@ -111,3 +111,3 @@ }

let range = self.get_range();
#[allow(clippy::unwrap_used)] // `self.get_range()` returns a valid range
#[expect(clippy::unwrap_used)] // `self.get_range()` returns a valid range
range.map(move |idx| {

@@ -131,3 +131,3 @@ (

let range = self.get_range();
#[allow(clippy::unwrap_used)] // `self.get_range()` returns a valid range
#[expect(clippy::unwrap_used)] // `self.get_range()` returns a valid range
range.map(move |idx| {

@@ -147,6 +147,6 @@ (

} else {
#[allow(clippy::unwrap_used)] // protected by the debug_assert above
#[expect(clippy::unwrap_used)] // protected by the debug_assert above
self.joiner.get(self.key0_index - 1).unwrap()
};
#[allow(clippy::unwrap_used)] // protected by the debug_assert above
#[expect(clippy::unwrap_used)] // protected by the debug_assert above
let limit = self.joiner.get(self.key0_index).unwrap();

@@ -198,3 +198,3 @@ // These two assertions are true based on the invariants of ZeroMap2d

let range = self.get_range();
#[allow(clippy::unwrap_used)] // `self.get_range()` returns a valid range
#[expect(clippy::unwrap_used)] // `self.get_range()` returns a valid range
range.map(move |idx| {

@@ -236,3 +236,3 @@ (

let range = self.get_range();
#[allow(clippy::unwrap_used)] // `self.get_range()` returns a valid range
#[expect(clippy::unwrap_used)] // `self.get_range()` returns a valid range
range.map(move |idx| {

@@ -250,3 +250,3 @@ (

V::Container::zvl_get_as_t(ule, |v| result.replace(*v));
#[allow(clippy::unwrap_used)] // `zvl_get_as_t` guarantees that the callback is invoked
#[expect(clippy::unwrap_used)] // `zvl_get_as_t` guarantees that the callback is invoked
Some(result.unwrap())

@@ -277,3 +277,3 @@ }

let key1_index = self.get_key1_index(key1)?;
#[allow(clippy::unwrap_used)] // key1_index is valid
#[expect(clippy::unwrap_used)] // key1_index is valid
Some(self.values.zvl_get(key1_index).unwrap())

@@ -294,3 +294,3 @@ }

let key1_index = self.get_key1_index_by(predicate)?;
#[allow(clippy::unwrap_used)] // key1_index is valid
#[expect(clippy::unwrap_used)] // key1_index is valid
Some(self.values.zvl_get(key1_index).unwrap())

@@ -305,3 +305,3 @@ }

let start = range.start;
#[allow(clippy::expect_used)] // protected by the debug_assert above
#[expect(clippy::expect_used)] // protected by the debug_assert above
let binary_search_result = self

@@ -320,3 +320,3 @@ .keys1

let start = range.start;
#[allow(clippy::expect_used)] // protected by the debug_assert above
#[expect(clippy::expect_used)] // protected by the debug_assert above
let binary_search_result = self

@@ -323,0 +323,0 @@ .keys1

@@ -245,3 +245,3 @@ // This file is part of ICU4X. For terms of use, please see the file

fn joiner_expand(&mut self, key0_index: usize) {
#[allow(clippy::expect_used)] // slice overflow
#[expect(clippy::expect_used)] // slice overflow
self.joiner

@@ -318,3 +318,3 @@ .to_mut_slice()

let range_start = range.start;
#[allow(clippy::unwrap_used)] // by debug_assert! invariants
#[expect(clippy::unwrap_used)] // by debug_assert! invariants
let index = range_start

@@ -354,3 +354,3 @@ + match self.keys1.zvl_binary_search_in_range(key1, range).unwrap() {

let is_singleton_range = range.start + 1 == range.end;
#[allow(clippy::unwrap_used)] // by debug_assert invariants
#[expect(clippy::unwrap_used)] // by debug_assert invariants
let index = range.start

@@ -414,6 +414,6 @@ + self

// The unwraps are protected by the fact that we are not empty
#[allow(clippy::unwrap_used)]
#[expect(clippy::unwrap_used)]
let last_key0 = self.keys0.zvl_get(self.keys0.zvl_len() - 1).unwrap();
let key0_cmp = K0::Container::t_cmp_get(key0, last_key0);
#[allow(clippy::unwrap_used)]
#[expect(clippy::unwrap_used)]
let last_key1 = self.keys1.zvl_get(self.keys1.zvl_len() - 1).unwrap();

@@ -440,3 +440,3 @@ let key1_cmp = K1::Container::t_cmp_get(key1, last_key1);

#[allow(clippy::expect_used)] // slice overflow
#[expect(clippy::expect_used)] // slice overflow
let joiner_value = u32::try_from(self.keys1.zvl_len() + 1)

@@ -446,3 +446,3 @@ .expect("Attempted to add more than 2^32 elements to a ZeroMap2d");

// All OK to append
#[allow(clippy::unwrap_used)]
#[expect(clippy::unwrap_used)]
if key0_cmp == Ordering::Greater {

@@ -468,3 +468,3 @@ self.keys0.zvl_push(key0);

#[cfg(debug_assertions)]
#[allow(clippy::unwrap_used)] // this is an assertion function
#[expect(clippy::unwrap_used)] // this is an assertion function
pub(crate) fn check_invariants(&self) {

@@ -573,3 +573,3 @@ debug_assert_eq!(self.keys0.zvl_len(), self.joiner.len());

// The unwrap is protected by the debug_assert above and key0_index != 0
#[allow(clippy::unwrap_used)]
#[expect(clippy::unwrap_used)]
self.joiner.get(key0_index - 1).unwrap()

@@ -576,0 +576,0 @@ };

@@ -104,3 +104,3 @@ // This file is part of ICU4X. For terms of use, please see the file

{
#[allow(clippy::type_complexity)] // it's a marker type, complexity doesn't matter
#[expect(clippy::type_complexity)] // it's a marker type, complexity doesn't matter
marker: PhantomData<fn() -> (&'a K0::OwnedType, &'a K1::OwnedType, &'a V::OwnedType)>,

@@ -176,3 +176,2 @@ }

struct TupleVecMapVisitor<K1, V> {
#[allow(clippy::type_complexity)] // it's a marker type, complexity doesn't matter
marker: PhantomData<fn() -> (K1, V)>,

@@ -179,0 +178,0 @@ }

@@ -87,3 +87,3 @@ // This file is part of ICU4X. For terms of use, please see the file

// TODO: Use slice::as_chunks() when stabilized
#[allow(clippy::indexing_slicing)]
#[expect(clippy::indexing_slicing)]
// Won't panic because the chunks are always 3 bytes long

@@ -90,0 +90,0 @@ let u = u32::from_le_bytes([chunk[0], chunk[1], chunk[2], 0]);

@@ -83,3 +83,3 @@ // This file is part of ICU4X. For terms of use, please see the file

self.encode_var_ule_as_slices(move |slices| {
#[allow(clippy::indexing_slicing)] // by debug_assert
#[expect(clippy::indexing_slicing)] // by debug_assert
for slice in slices {

@@ -257,3 +257,3 @@ dst[..slice.len()].copy_from_slice(slice);

#[allow(clippy::unwrap_used)] // TODO(#1410): Rethink length errors in VZV.
#[expect(clippy::unwrap_used)] // TODO(#1410): Rethink length errors in VZV.
fn encode_var_ule_len(&self) -> usize {

@@ -260,0 +260,0 @@ crate::varzerovec::components::compute_serializable_len::<T, E, F>(self).unwrap() as usize

@@ -18,3 +18,3 @@ // This file is part of ICU4X. For terms of use, please see the file

// Won't panic because i < N and arr has length N
#[allow(clippy::indexing_slicing)]
#[expect(clippy::indexing_slicing)]
while i < N {

@@ -21,0 +21,0 @@ result[i] = $single(arr[i]);

@@ -150,3 +150,2 @@ // This file is part of ICU4X. For terms of use, please see the file

#[inline]
#[allow(clippy::wrong_self_convention)] // https://github.com/rust-lang/rust-clippy/issues/7219
fn slice_as_bytes(slice: &[Self]) -> &[u8] {

@@ -153,0 +152,0 @@ unsafe {

@@ -27,3 +27,3 @@ // This file is part of ICU4X. For terms of use, please see the file

#[inline]
#[allow(clippy::expect_used)] // See #1410
#[expect(clippy::expect_used)] // See #1410
pub fn compute_encoded_len_for(lengths: [usize; LEN]) -> usize {

@@ -30,0 +30,0 @@ let lengths = lengths.map(BlankSliceEncoder);

@@ -161,3 +161,3 @@ // This file is part of ICU4X. For terms of use, please see the file

/// [`repr(transparent)`] guarantees that the layout is same as [`Option<U>`]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(transparent)]

@@ -164,0 +164,0 @@ #[allow(clippy::exhaustive_structs)] // newtype

@@ -82,3 +82,3 @@ // This file is part of ICU4X. For terms of use, please see the file

for chunk in bytes.chunks(size) {
#[allow(clippy::indexing_slicing)] // `chunk` will have enough bytes to fit Self
#[expect(clippy::indexing_slicing)] // `chunk` will have enough bytes to fit Self
match chunk[0] {

@@ -183,3 +183,3 @@ // https://doc.rust-lang.org/reference/types/boolean.html

}
#[allow(clippy::indexing_slicing)] // slice already verified to be nonempty
#[expect(clippy::indexing_slicing)] // slice already verified to be nonempty
match slice[0] {

@@ -229,3 +229,3 @@ // https://doc.rust-lang.org/reference/types/boolean.html

#[allow(clippy::indexing_slicing)] // This method is allowed to panic when lengths are invalid
#[expect(clippy::indexing_slicing)] // This method is allowed to panic when lengths are invalid
fn encode_var_ule_write(&self, dst: &mut [u8]) {

@@ -232,0 +232,0 @@ if let Some(ref inner) = *self {

@@ -59,3 +59,3 @@ // This file is part of ICU4X. For terms of use, please see the file

i += mem::size_of::<$t>();
#[allow(clippy::indexing_slicing)] // length checked
#[expect(clippy::indexing_slicing)] // length checked
<$t>::validate_bytes(&chunk[j..i])?;

@@ -62,0 +62,0 @@ )+

@@ -39,3 +39,2 @@ // This file is part of ICU4X. For terms of use, please see the file

/// and all of its associated items are hidden from the docs.
#[allow(clippy::missing_safety_doc)] // no safety section for you, don't implement this trait period
#[doc(hidden)]

@@ -436,3 +435,3 @@ pub unsafe trait IntegerULE: ULE {

#[inline]
#[allow(clippy::len_zero)] // more explicit to enforce safety invariants
#[expect(clippy::len_zero)] // more explicit to enforce safety invariants
fn check_indices_and_things(self) -> Result<(), VarZeroVecFormatError> {

@@ -734,3 +733,3 @@ if self.len() == 0 {

let idx_limit = idx_offset + F::Index::SIZE;
#[allow(clippy::indexing_slicing)] // Function contract allows panicky behavior
#[expect(clippy::indexing_slicing)] // Function contract allows panicky behavior
let idx_slice = &mut output[idx_offset..idx_limit];

@@ -740,3 +739,3 @@ // VZV expects data offsets to be stored relative to the first data block

assert!(idx <= F::Index::MAX_VALUE as usize);
#[allow(clippy::expect_used)] // this function is explicitly panicky
#[expect(clippy::expect_used)] // this function is explicitly panicky
let bytes_to_write = F::Index::iule_from_usize(idx).expect(F::Index::TOO_LARGE_ERROR);

@@ -749,3 +748,3 @@ idx_slice.copy_from_slice(ULE::slice_as_bytes(&[bytes_to_write]));

let dat_limit = dat_offset + element_len;
#[allow(clippy::indexing_slicing)] // Function contract allows panicky behavior
#[expect(clippy::indexing_slicing)] // Function contract allows panicky behavior
let dat_slice = &mut output[dat_offset..dat_limit];

@@ -778,8 +777,8 @@ element.encode_var_ule_write(dat_slice);

assert!(elements.len() <= F::Len::MAX_VALUE as usize);
#[allow(clippy::expect_used)] // This function is explicitly panicky
#[expect(clippy::expect_used)] // This function is explicitly panicky
let num_elements_ule = F::Len::iule_from_usize(elements.len()).expect(F::Len::TOO_LARGE_ERROR);
#[allow(clippy::indexing_slicing)] // Function contract allows panicky behavior
#[expect(clippy::indexing_slicing)] // Function contract allows panicky behavior
output[0..F::Len::SIZE].copy_from_slice(ULE::slice_as_bytes(&[num_elements_ule]));
#[allow(clippy::indexing_slicing)] // Function contract allows panicky behavior
#[expect(clippy::indexing_slicing)] // Function contract allows panicky behavior
write_serializable_bytes_without_length::<T, A, F>(elements, &mut output[F::Len::SIZE..]);

@@ -786,0 +785,0 @@ }

@@ -16,3 +16,4 @@ // This file is part of ICU4X. For terms of use, please see the file

let bytes = databake::Bake::bake(&self.as_bytes(), env);
// Safe because self.as_bytes is a safe input
// Safety: bytes was obtained from a VarZeroVec via as_bytes() above,
// and thus is valid for unchecked construction.
quote! { unsafe { zerovec::vecs::VarZeroVec16::from_bytes_unchecked(#bytes) } }

@@ -30,3 +31,4 @@ }

let bytes = databake::Bake::bake(&self.as_bytes(), env);
// Safe because self.as_bytes is a safe input
// Safety: bytes was obtained from a VarZeroVec via as_bytes() above,
// and thus is valid for unchecked construction.
quote! { unsafe { zerovec::vecs::VarZeroVec32::from_bytes_unchecked(#bytes) } }

@@ -56,3 +58,4 @@ }

let bytes = databake::Bake::bake(&self.as_bytes(), env);
// Safe because self.as_bytes is a safe input
// Safety: bytes was obtained from a VarZeroSlice via as_bytes() above,
// and thus is valid for unchecked construction.
quote! { unsafe { zerovec::vecs::VarZeroSlice16::from_bytes_unchecked(#bytes) } }

@@ -70,3 +73,4 @@ }

let bytes = databake::Bake::bake(&self.as_bytes(), env);
// Safe because self.as_bytes is a safe input
// Safety: bytes was obtained from a VarZeroSlice via as_bytes() above,
// and thus is valid for unchecked construction.
quote! { unsafe { zerovec::vecs::VarZeroSlice32::from_bytes_unchecked(#bytes) } }

@@ -73,0 +77,0 @@ }

@@ -113,5 +113,5 @@ // This file is part of ICU4X. For terms of use, please see the file

// returns a range in-bounds of the things slice
#[allow(clippy::indexing_slicing)]
#[expect(clippy::indexing_slicing)]
&mut self.entire_slice[offset..][range]
}
}

@@ -16,3 +16,3 @@ // This file is part of ICU4X. For terms of use, please see the file

struct VarZeroVecVisitor<T: ?Sized, F: VarZeroVecFormat> {
#[allow(clippy::type_complexity)] // this is a private marker type, who cares
#[expect(clippy::type_complexity)] // this is a private marker type, who cares
marker: PhantomData<(fn() -> Box<T>, F)>,

@@ -19,0 +19,0 @@ }

@@ -462,3 +462,3 @@ // This file is part of ICU4X. For terms of use, please see the file

fn index(&self, index: usize) -> &Self::Output {
#[allow(clippy::panic)] // documented
#[expect(clippy::panic)] // documented
match self.get(index) {

@@ -465,0 +465,0 @@ Some(x) => x,

@@ -195,3 +195,3 @@ // This file is part of ICU4X. For terms of use, please see the file

impl<T: VarULE + ?Sized> Default for VarZeroVec<'_, T> {
impl<T: VarULE + ?Sized, F: VarZeroVecFormat> Default for VarZeroVec<'_, T, F> {
#[inline]

@@ -399,3 +399,3 @@ fn default() -> Self {

} else {
#[allow(clippy::unwrap_used)] // TODO(#1410) Better story for fallibility
#[expect(clippy::unwrap_used)] // TODO(#1410) Better story for fallibility
VarZeroVecOwned::try_from_elements(elements).unwrap().into()

@@ -402,0 +402,0 @@ }

@@ -110,3 +110,2 @@ // This file is part of ICU4X. For terms of use, please see the file

/// This impl requires enabling the optional `yoke` Cargo feature of the `zerovec` crate
#[allow(clippy::transmute_ptr_to_ptr)]
#[cfg(feature = "alloc")]

@@ -158,3 +157,2 @@ unsafe impl<'a, K, V> Yokeable<'a> for ZeroMap<'static, K, V>

/// This impl requires enabling the optional `yoke` Cargo feature of the `zerovec` crate
#[allow(clippy::transmute_ptr_to_ptr)]
#[cfg(feature = "alloc")]

@@ -206,3 +204,2 @@ unsafe impl<'a, K, V> Yokeable<'a> for ZeroMapBorrowed<'static, K, V>

/// This impl requires enabling the optional `yoke` Cargo feature of the `zerovec` crate
#[allow(clippy::transmute_ptr_to_ptr)]
#[cfg(feature = "alloc")]

@@ -256,3 +253,2 @@ unsafe impl<'a, K0, K1, V> Yokeable<'a> for ZeroMap2d<'static, K0, K1, V>

/// This impl requires enabling the optional `yoke` Cargo feature of the `zerovec` crate
#[allow(clippy::transmute_ptr_to_ptr)]
#[cfg(feature = "alloc")]

@@ -321,3 +317,3 @@ unsafe impl<'a, K0, K1, V> Yokeable<'a> for ZeroMap2dBorrowed<'static, K0, K1, V>

#[cfg_attr(feature = "serde", serde(borrow))]
_data: ZeroVec<'data, u16>,
pub _data: ZeroVec<'data, u16>,
}

@@ -342,3 +338,3 @@

#[cfg_attr(feature = "serde", serde(borrow))]
_data: &'data ZeroSlice<u16>,
pub _data: &'data ZeroSlice<u16>,
}

@@ -363,3 +359,3 @@

#[cfg_attr(feature = "serde", serde(borrow))]
_data: VarZeroVec<'data, str>,
pub _data: VarZeroVec<'data, str>,
}

@@ -384,3 +380,3 @@

#[cfg_attr(feature = "serde", serde(borrow))]
_data: &'data VarZeroSlice<str>,
pub _data: &'data VarZeroSlice<str>,
}

@@ -406,3 +402,3 @@

#[cfg_attr(feature = "serde", serde(borrow))]
_data: ZeroMap<'data, [u8], str>,
pub _data: ZeroMap<'data, [u8], str>,
}

@@ -434,3 +430,3 @@

#[cfg_attr(feature = "serde", serde(borrow))]
_data: ZeroMapBorrowed<'data, [u8], str>,
pub _data: ZeroMapBorrowed<'data, [u8], str>,
}

@@ -462,3 +458,3 @@

#[cfg_attr(feature = "serde", serde(borrow))]
_data: ZeroMap<'data, ZeroSlice<u32>, str>,
pub _data: ZeroMap<'data, ZeroSlice<u32>, str>,
}

@@ -490,3 +486,3 @@

#[cfg_attr(feature = "serde", serde(borrow))]
_data: ZeroMap2d<'data, u16, u16, str>,
pub _data: ZeroMap2d<'data, u16, u16, str>,
}

@@ -520,3 +516,3 @@

#[cfg_attr(feature = "serde", serde(borrow))]
_data: ZeroMap2dBorrowed<'data, u16, u16, str>,
pub _data: ZeroMap2dBorrowed<'data, u16, u16, str>,
}

@@ -523,0 +519,0 @@

@@ -16,2 +16,4 @@ // This file is part of ICU4X. For terms of use, please see the file

let bytes = databake::Bake::bake(&self.as_bytes(), env);
// Safety: bytes was obtained from a ZeroVec via as_bytes() above,
// and thus is valid for unchecked construction.
quote! { unsafe { zerovec::ZeroVec::from_bytes_unchecked(#bytes) } }

@@ -35,2 +37,4 @@ }

let bytes = databake::Bake::bake(&self.as_bytes(), env);
// Safety: bytes was obtained from a ZeroSlice via as_bytes() above,
// and thus is valid for unchecked construction.
quote! { unsafe { zerovec::ZeroSlice::from_bytes_unchecked(#bytes) } }

@@ -37,0 +41,0 @@ }

@@ -168,2 +168,13 @@ // This file is part of ICU4X. For terms of use, please see the file

}
fn truncate(&mut self, max: usize) {
// SAFETY: The elements in buf are `ULE`, so they don't need to be dropped
// even if we own them.
self.buf = unsafe {
NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(
self.buf.as_mut().as_mut_ptr(),
core::cmp::max(max, self.buf.as_ref().len()),
))
};
}
}

@@ -1072,2 +1083,9 @@

}
/// Truncates this vector to `min(self.len(), max)`.
#[inline]
pub fn truncated(mut self, max: usize) -> Self {
self.vector.truncate(max);
self
}
}

@@ -1074,0 +1092,0 @@

@@ -396,3 +396,3 @@ // This file is part of ICU4X. For terms of use, please see the file

// `unwrap()` must succeed, because `first()` returned `Some`.
#[allow(clippy::unwrap_used)]
#[expect(clippy::unwrap_used)]
self.get_subslice(1..self.len()).unwrap(),

@@ -414,2 +414,6 @@ ));

}
fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
}

@@ -416,0 +420,0 @@

Sorry, the diff of this file is not supported yet