Skip to content

Commit 0788e84

Browse files
authored
Merge pull request #20909 from taj-p/master
Rename `downcast_[ref|mut]_unchecked` -> `downcast_unchecked_[ref|mut]`
2 parents d26e4b2 + 291cc5d commit 0788e84

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

crates/stdx/src/anymap.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<A: ?Sized + Downcast> Map<A> {
117117
#[inline]
118118
#[must_use]
119119
pub fn get<T: IntoBox<A>>(&self) -> Option<&T> {
120-
self.raw.get(&TypeId::of::<T>()).map(|any| unsafe { any.downcast_ref_unchecked::<T>() })
120+
self.raw.get(&TypeId::of::<T>()).map(|any| unsafe { any.downcast_unchecked_ref::<T>() })
121121
}
122122

123123
/// Gets the entry for the given type in the collection for in-place manipulation
@@ -172,7 +172,7 @@ impl<'map, A: ?Sized + Downcast, V: IntoBox<A>> OccupiedEntry<'map, A, V> {
172172
#[inline]
173173
#[must_use]
174174
pub fn into_mut(self) -> &'map mut V {
175-
unsafe { self.inner.into_mut().downcast_mut_unchecked() }
175+
unsafe { self.inner.into_mut().downcast_unchecked_mut() }
176176
}
177177
}
178178

@@ -181,7 +181,7 @@ impl<'map, A: ?Sized + Downcast, V: IntoBox<A>> VacantEntry<'map, A, V> {
181181
/// and returns a mutable reference to it
182182
#[inline]
183183
pub fn insert(self, value: V) -> &'map mut V {
184-
unsafe { self.inner.insert(value.into_box()).downcast_mut_unchecked() }
184+
unsafe { self.inner.insert(value.into_box()).downcast_unchecked_mut() }
185185
}
186186
}
187187

@@ -244,14 +244,14 @@ pub trait Downcast {
244244
/// # Safety
245245
///
246246
/// The caller must ensure that `T` matches the trait object, on pain of *undefined behavior*.
247-
unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &T;
247+
unsafe fn downcast_unchecked_ref<T: 'static>(&self) -> &T;
248248

249249
/// Downcast from `&mut Any` to `&mut T`, without checking the type matches.
250250
///
251251
/// # Safety
252252
///
253253
/// The caller must ensure that `T` matches the trait object, on pain of *undefined behavior*.
254-
unsafe fn downcast_mut_unchecked<T: 'static>(&mut self) -> &mut T;
254+
unsafe fn downcast_unchecked_mut<T: 'static>(&mut self) -> &mut T;
255255
}
256256

257257
/// A trait for the conversion of an object into a boxed trait object.
@@ -269,12 +269,12 @@ macro_rules! implement {
269269
}
270270

271271
#[inline]
272-
unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &T {
272+
unsafe fn downcast_unchecked_ref<T: 'static>(&self) -> &T {
273273
unsafe { &*std::ptr::from_ref::<Self>(self).cast::<T>() }
274274
}
275275

276276
#[inline]
277-
unsafe fn downcast_mut_unchecked<T: 'static>(&mut self) -> &mut T {
277+
unsafe fn downcast_unchecked_mut<T: 'static>(&mut self) -> &mut T {
278278
unsafe { &mut *std::ptr::from_mut::<Self>(self).cast::<T>() }
279279
}
280280
}

0 commit comments

Comments
 (0)