🌐 AI搜索 & 代理 主页
Skip to content

Commit 9134a20

Browse files
committed
more typo fixes
1 parent 97a8109 commit 9134a20

File tree

2 files changed

+35
-38
lines changed

2 files changed

+35
-38
lines changed

turbopack/crates/turbo-frozenmap/src/map.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
1919
/// # Construction
2020
///
2121
/// If you're building a new map, and you don't expect many overlapping keys, consider pushing
22-
/// elements into a [`Vec<(K, V)>`] and calling [`FrozenMap::from`]. It is typically cheaper to
22+
/// entries into a [`Vec<(K, V)>`] and calling [`FrozenMap::from`]. It is typically cheaper to
2323
/// collect into a [`Vec`] and sort the entries once at the end than it is to maintain a temporary
2424
/// map data structure.
2525
///
@@ -37,7 +37,7 @@ use serde::{Deserialize, Serialize};
3737
/// constructors, which provide the cheapest possible construction.
3838
///
3939
/// Overlapping keys encountered during construction preserve the last overlapping entry, matching
40-
/// similar behavior for other sets in the standard library.
40+
/// similar behavior for other maps in the standard library.
4141
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Encode, Decode, Serialize, Deserialize)]
4242
#[rustfmt::skip] // rustfmt breaks bincode's proc macro string processing
4343
#[bincode(
@@ -124,15 +124,15 @@ where
124124
fn assert_unique_sorted<K: Ord, V>(entries: &[(K, V)]) {
125125
assert!(
126126
entries.is_sorted_by(|a, b| a.0 < b.0),
127-
"FrozenMap entries must be sorted and unique",
127+
"FrozenMap entries must be unique and sorted",
128128
)
129129
}
130130

131131
#[track_caller]
132132
fn debug_assert_unique_sorted<K: Ord, V>(entries: &[(K, V)]) {
133133
debug_assert!(
134134
entries.is_sorted_by(|a, b| a.0 < b.0),
135-
"FrozenMap entries must be sorted and unique",
135+
"FrozenMap entries must be unique and sorted",
136136
)
137137
}
138138

@@ -194,7 +194,7 @@ where
194194
}
195195

196196
impl<K: Ord, V> From<Vec<(K, V)>> for FrozenMap<K, V> {
197-
/// Creates a [`FrozenMap`] from an array of key-value pairs.
197+
/// Creates a [`FrozenMap`] from a [`Vec`] of key-value pairs.
198198
///
199199
/// If there are overlapping keys, the last entry for each key is kept.
200200
fn from(entries: Vec<(K, V)>) -> Self {
@@ -206,7 +206,7 @@ impl<K: Ord, V> From<Vec<(K, V)>> for FrozenMap<K, V> {
206206
}
207207

208208
impl<K: Ord, V> From<Box<[(K, V)]>> for FrozenMap<K, V> {
209-
/// Creates a [`FrozenMap`] from an array of key-value pairs.
209+
/// Creates a [`FrozenMap`] from a boxed slice of key-value pairs.
210210
///
211211
/// If there are overlapping keys, the last entry for each key is kept.
212212
fn from(entries: Box<[(K, V)]>) -> Self {
@@ -336,7 +336,7 @@ impl<K, V> FrozenMap<K, V> {
336336
}
337337
}
338338

339-
/// Constructs a double-ended iterator over a sub-range of elements in the map.
339+
/// Constructs a double-ended iterator over a sub-range of entries in the map.
340340
pub fn range<T, R>(&self, range: R) -> Range<'_, K, V>
341341
where
342342
T: Ord + ?Sized,
@@ -908,7 +908,7 @@ mod tests {
908908
}
909909

910910
#[test]
911-
#[should_panic(expected = "FrozenMap entries must be sorted and unique")]
911+
#[should_panic(expected = "FrozenMap entries must be unique and sorted")]
912912
fn test_from_unique_sorted_box_panics() {
913913
let _ = FrozenMap::from_unique_sorted_box(Box::from([(1, "a"), (1, "b")]));
914914
}

turbopack/crates/turbo-frozenmap/src/set.rs

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::map::{self, FrozenMap};
2121
/// # Construction
2222
///
2323
/// If you're building a new set, and you don't expect many overlapping items, consider pushing
24-
/// elements into a [`Vec`] and calling [`FrozenSet::from`] or using the [`FromIterator`]
24+
/// items into a [`Vec`] and calling [`FrozenSet::from`] or using the [`FromIterator`]
2525
/// implementation via [`Iterator::collect`]. It is typically cheaper to collect into a [`Vec`] and
2626
/// sort the items once at the end than it is to maintain a temporary set data structure.
2727
///
@@ -30,7 +30,7 @@ use crate::map::{self, FrozenMap};
3030
/// many common collections. You should prefer using a [`BTreeSet`], as it matches the sorted
3131
/// semantics of [`FrozenSet`] and avoids a sort operation during conversion.
3232
///
33-
/// Overlapping keys encountered during construction preserve the last overlapping entry, matching
33+
/// Overlapping items encountered during construction preserve the last overlapping item, matching
3434
/// similar behavior for other sets in the standard library.
3535
///
3636
/// Similar to the API of [`BTreeSet`], there are no convenience methods for constructing from a
@@ -65,10 +65,7 @@ where
6565
/// that the iterator is sorted and has no overlapping items.
6666
///
6767
/// Panics if the `items` are not unique and sorted.
68-
pub fn from_unique_sorted_iter(items: impl IntoIterator<Item = T>) -> Self
69-
where
70-
T: Ord,
71-
{
68+
pub fn from_unique_sorted_iter(items: impl IntoIterator<Item = T>) -> Self {
7269
FrozenSet {
7370
map: FrozenMap::from_unique_sorted_box(items.into_iter().map(|t| (t, ())).collect()),
7471
}
@@ -82,7 +79,7 @@ where
8279
/// # Correctness
8380
///
8481
/// The caller must ensure that:
85-
/// - The iterator yields elements in ascending order according to [`T: Ord`][Ord]
82+
/// - The iterator yields items in ascending order according to [`T: Ord`][Ord]
8683
/// - There are no overlapping items
8784
///
8885
/// If these invariants are not upheld, the set will behave incorrectly (e.g.,
@@ -100,8 +97,8 @@ where
10097
}
10198

10299
impl<T: Ord> FromIterator<T> for FrozenSet<T> {
103-
/// Creates a [`FrozenSet`] from an iterator of elements. If there are overlapping elements,
104-
/// only the last copy is kept.
100+
/// Creates a [`FrozenSet`] from an iterator of items. If there are overlapping items, only the
101+
/// last copy is kept.
105102
fn from_iter<I: IntoIterator<Item = T>>(items: I) -> Self {
106103
FrozenSet {
107104
map: FrozenMap::from_iter(items.into_iter().map(|t| (t, ()))),
@@ -112,7 +109,7 @@ impl<T: Ord> FromIterator<T> for FrozenSet<T> {
112109
impl<T> From<BTreeSet<T>> for FrozenSet<T> {
113110
/// Creates a [`FrozenSet`] from a [`BTreeSet`].
114111
///
115-
/// This is more efficient than [`From<HashSet<T>>`] because [`BTreeSet`] already iterates in
112+
/// This is more efficient than `From<HashSet<T>>` because [`BTreeSet`] already iterates in
116113
/// sorted order, so no re-sorting is needed.
117114
fn from(set: BTreeSet<T>) -> Self {
118115
if set.is_empty() {
@@ -133,7 +130,7 @@ where
133130
{
134131
/// Creates a [`FrozenSet`] from a [`HashSet`].
135132
///
136-
/// The elements are sorted during construction.
133+
/// The items are sorted during construction.
137134
fn from(set: HashSet<T, S>) -> Self {
138135
if set.is_empty() {
139136
return Self::new();
@@ -151,7 +148,7 @@ where
151148
{
152149
/// Creates a [`FrozenSet`] from an [`IndexSet`].
153150
///
154-
/// The elements are sorted during construction.
151+
/// The items are sorted during construction.
155152
fn from(set: IndexSet<T, S>) -> Self {
156153
if set.is_empty() {
157154
return Self::new();
@@ -163,12 +160,12 @@ where
163160
}
164161

165162
impl<T: Ord, const N: usize> From<[T; N]> for FrozenSet<T> {
166-
/// Creates a [`FrozenSet`] from an array of elements. If there are overlapping elements, the
167-
/// last copy is kept.
163+
/// Creates a [`FrozenSet`] from an array of items. If there are overlapping items, the last
164+
/// copy is kept.
168165
///
169-
/// The elements are sorted during construction.
170-
fn from(elements: [T; N]) -> Self {
171-
Self::from_iter(elements)
166+
/// The items are sorted during construction.
167+
fn from(items: [T; N]) -> Self {
168+
Self::from_iter(items)
172169
}
173170
}
174171

@@ -201,14 +198,14 @@ impl<T> FrozenSet<T> {
201198
self.map.get_key_value(value).map(|(t, _)| t)
202199
}
203200

204-
/// Returns a reference to the first element in the set, if any.
205-
/// This element is always the minimum of all elements in the set.
201+
/// Returns a reference to the first element in the set, if any. This element is always the
202+
/// minimum of all elements in the set.
206203
pub fn first(&self) -> Option<&T> {
207204
self.map.first_key_value().map(|(t, _)| t)
208205
}
209206

210-
/// Returns a reference to the last element in the set, if any.
211-
/// This element is always the maximum of all elements in the set.
207+
/// Returns a reference to the last element in the set, if any. This element is always the
208+
/// maximum of all elements in the set.
212209
pub fn last(&self) -> Option<&T> {
213210
self.map.last_key_value().map(|(t, _)| t)
214211
}
@@ -230,8 +227,8 @@ impl<T> FrozenSet<T> {
230227
}
231228
}
232229

233-
/// Returns `true` if `self` has no elements in common with `other`.
234-
/// This is equivalent to checking for an empty intersection.
230+
/// Returns `true` if `self` has no elements in common with `other`. This is equivalent to
231+
/// checking for an empty intersection.
235232
pub fn is_disjoint(&self, other: &Self) -> bool
236233
where
237234
T: Ord,
@@ -243,8 +240,8 @@ impl<T> FrozenSet<T> {
243240
}
244241
}
245242

246-
/// Returns `true` if the set is a subset of another,
247-
/// i.e., `other` contains at least all the elements in `self`.
243+
/// Returns `true` if the set is a subset of another, i.e., `other` contains at least all the
244+
/// elements in `self`.
248245
pub fn is_subset(&self, other: &Self) -> bool
249246
where
250247
T: Ord,
@@ -255,8 +252,8 @@ impl<T> FrozenSet<T> {
255252
self.iter().all(|v| other.contains(v))
256253
}
257254

258-
/// Returns `true` if the set is a superset of another,
259-
/// i.e., `self` contains at least all the elements in `other`.
255+
/// Returns `true` if the set is a superset of another, i.e., `self` contains at least all the
256+
/// elements in `other`.
260257
pub fn is_superset(&self, other: &Self) -> bool
261258
where
262259
T: Ord,
@@ -297,8 +294,8 @@ impl<T> IntoIterator for FrozenSet<T> {
297294
}
298295

299296
// These could be newtype wrappers (BTreeSet does this), but type aliases are simpler to implement.
300-
type Iter<'a, T> = map::Keys<'a, T, ()>;
301-
type IntoIter<T> = map::IntoKeys<T, ()>;
297+
pub type Iter<'a, T> = map::Keys<'a, T, ()>;
298+
pub type IntoIter<T> = map::IntoKeys<T, ()>;
302299

303300
/// An iterator over a sub-range of elements in a [`FrozenSet`].
304301
pub struct Range<'a, T> {
@@ -481,7 +478,7 @@ mod tests {
481478
}
482479

483480
#[test]
484-
#[should_panic(expected = "FrozenMap entries must be sorted and unique")]
481+
#[should_panic(expected = "FrozenMap entries must be unique and sorted")]
485482
fn test_from_unique_sorted_iter_panics() {
486483
let _ = FrozenSet::from_unique_sorted_iter([1, 1, 2]);
487484
}

0 commit comments

Comments
 (0)