From 183331a695fb29a28e3fd32621504ed1db550482 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Fri, 15 Oct 2021 13:51:06 +0100 Subject: [PATCH] Rename IdSlice[Mut] -> SliceId[Mut] and their methods To conform with the C-WORD-ORDER guideline: https://rust-lang.github.io/api-guidelines/naming.html#c-word-order --- objc2/src/rc/id_traits.rs | 18 ++++++++++-------- objc2/src/rc/mod.rs | 2 +- objc2_foundation/src/array.rs | 2 +- objc2_foundation/src/dictionary.rs | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/objc2/src/rc/id_traits.rs b/objc2/src/rc/id_traits.rs index 8d7874290..341474d9f 100644 --- a/objc2/src/rc/id_traits.rs +++ b/objc2/src/rc/id_traits.rs @@ -1,8 +1,10 @@ +//! Helper traits for Id. + use super::{Id, Owned, Ownership}; use crate::Message; /// Helper trait for functionality on slices containing [`Id`]s. -pub trait IdSlice { +pub trait SliceId { /// The type of the items in the slice. type Item; @@ -10,20 +12,20 @@ pub trait IdSlice { fn as_slice_ref(&self) -> &[&Self::Item]; /// Convert a mutable slice of [`Id`]s into a mutable slice of references. - fn as_slice_mut_ref(&mut self) -> &mut [&Self::Item]; + fn as_slice_mut(&mut self) -> &mut [&Self::Item]; } /// Helper trait for functionality on slices containing owned [`Id`]s. -pub trait IdSliceMut { +pub trait SliceIdMut { /// The type of the items in the slice. type Item; /// Convert a mutable slice of mutable [`Id`]s into a mutable slice of /// mutable references. - fn as_mut_slice_mut_ref(&mut self) -> &mut [&mut Self::Item]; + fn as_mut_slice_mut(&mut self) -> &mut [&mut Self::Item]; } -impl IdSlice for [Id] { +impl SliceId for [Id] { type Item = T; fn as_slice_ref(&self) -> &[&T] { @@ -33,7 +35,7 @@ impl IdSlice for [Id] { unsafe { &*ptr } } - fn as_slice_mut_ref(&mut self) -> &mut [&T] { + fn as_slice_mut(&mut self) -> &mut [&T] { let ptr = self as *mut Self as *mut [&T]; // SAFETY: Id and &T have the same memory layout. Further safety // follows from `Deref` impl. @@ -41,10 +43,10 @@ impl IdSlice for [Id] { } } -impl IdSliceMut for [Id] { +impl SliceIdMut for [Id] { type Item = T; - fn as_mut_slice_mut_ref(&mut self) -> &mut [&mut T] { + fn as_mut_slice_mut(&mut self) -> &mut [&mut T] { let ptr = self as *mut Self as *mut [&mut T]; // SAFETY: Id and &mut T have the same memory layout, and the // `Id` is `Owned` so we're allowed to hand out mutable references. diff --git a/objc2/src/rc/mod.rs b/objc2/src/rc/mod.rs index 45de6230d..c52b8a1ca 100644 --- a/objc2/src/rc/mod.rs +++ b/objc2/src/rc/mod.rs @@ -35,7 +35,7 @@ mod weak_id; pub use self::autorelease::{autoreleasepool, AutoreleasePool, AutoreleaseSafe}; pub use self::id::Id; -pub use self::id_traits::{IdSlice, IdSliceMut}; +pub use self::id_traits::{SliceId, SliceIdMut}; pub use self::ownership::{Owned, Ownership, Shared}; pub use self::weak_id::WeakId; diff --git a/objc2_foundation/src/array.rs b/objc2_foundation/src/array.rs index cd5feaea2..d1b6dcb97 100644 --- a/objc2_foundation/src/array.rs +++ b/objc2_foundation/src/array.rs @@ -5,7 +5,7 @@ use core::marker::PhantomData; use core::ops::{Index, Range}; use core::ptr::NonNull; -use objc2::rc::{Id, IdSlice, Owned, Ownership, Shared}; +use objc2::rc::{Id, Owned, Ownership, Shared, SliceId}; use objc2::runtime::{Class, Object}; use objc2::{class, msg_send}; use objc2::{Encode, Encoding}; diff --git a/objc2_foundation/src/dictionary.rs b/objc2_foundation/src/dictionary.rs index b2d436b2e..d119ba8a4 100644 --- a/objc2_foundation/src/dictionary.rs +++ b/objc2_foundation/src/dictionary.rs @@ -4,7 +4,7 @@ use core::marker::PhantomData; use core::ops::Index; use core::ptr::{self, NonNull}; -use objc2::rc::{Id, IdSlice, Owned, Ownership, Shared}; +use objc2::rc::{Id, Owned, Ownership, Shared, SliceId}; use objc2::runtime::Class; use objc2::{class, msg_send};