Skip to content

Commit 183331a

Browse files
committed
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
1 parent 8c83d01 commit 183331a

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

objc2/src/rc/id_traits.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1+
//! Helper traits for Id.
2+
13
use super::{Id, Owned, Ownership};
24
use crate::Message;
35

46
/// Helper trait for functionality on slices containing [`Id`]s.
5-
pub trait IdSlice {
7+
pub trait SliceId {
68
/// The type of the items in the slice.
79
type Item;
810

911
/// Convert a slice of [`Id`]s into a slice of references.
1012
fn as_slice_ref(&self) -> &[&Self::Item];
1113

1214
/// Convert a mutable slice of [`Id`]s into a mutable slice of references.
13-
fn as_slice_mut_ref(&mut self) -> &mut [&Self::Item];
15+
fn as_slice_mut(&mut self) -> &mut [&Self::Item];
1416
}
1517

1618
/// Helper trait for functionality on slices containing owned [`Id`]s.
17-
pub trait IdSliceMut {
19+
pub trait SliceIdMut {
1820
/// The type of the items in the slice.
1921
type Item;
2022

2123
/// Convert a mutable slice of mutable [`Id`]s into a mutable slice of
2224
/// mutable references.
23-
fn as_mut_slice_mut_ref(&mut self) -> &mut [&mut Self::Item];
25+
fn as_mut_slice_mut(&mut self) -> &mut [&mut Self::Item];
2426
}
2527

26-
impl<T: Message, O: Ownership> IdSlice for [Id<T, O>] {
28+
impl<T: Message, O: Ownership> SliceId for [Id<T, O>] {
2729
type Item = T;
2830

2931
fn as_slice_ref(&self) -> &[&T] {
@@ -33,18 +35,18 @@ impl<T: Message, O: Ownership> IdSlice for [Id<T, O>] {
3335
unsafe { &*ptr }
3436
}
3537

36-
fn as_slice_mut_ref(&mut self) -> &mut [&T] {
38+
fn as_slice_mut(&mut self) -> &mut [&T] {
3739
let ptr = self as *mut Self as *mut [&T];
3840
// SAFETY: Id<T, O> and &T have the same memory layout. Further safety
3941
// follows from `Deref` impl.
4042
unsafe { &mut *ptr }
4143
}
4244
}
4345

44-
impl<T: Message> IdSliceMut for [Id<T, Owned>] {
46+
impl<T: Message> SliceIdMut for [Id<T, Owned>] {
4547
type Item = T;
4648

47-
fn as_mut_slice_mut_ref(&mut self) -> &mut [&mut T] {
49+
fn as_mut_slice_mut(&mut self) -> &mut [&mut T] {
4850
let ptr = self as *mut Self as *mut [&mut T];
4951
// SAFETY: Id<T, O> and &mut T have the same memory layout, and the
5052
// `Id` is `Owned` so we're allowed to hand out mutable references.

objc2/src/rc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ mod weak_id;
3535

3636
pub use self::autorelease::{autoreleasepool, AutoreleasePool, AutoreleaseSafe};
3737
pub use self::id::Id;
38-
pub use self::id_traits::{IdSlice, IdSliceMut};
38+
pub use self::id_traits::{SliceId, SliceIdMut};
3939
pub use self::ownership::{Owned, Ownership, Shared};
4040
pub use self::weak_id::WeakId;
4141

objc2_foundation/src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::marker::PhantomData;
55
use core::ops::{Index, Range};
66
use core::ptr::NonNull;
77

8-
use objc2::rc::{Id, IdSlice, Owned, Ownership, Shared};
8+
use objc2::rc::{Id, Owned, Ownership, Shared, SliceId};
99
use objc2::runtime::{Class, Object};
1010
use objc2::{class, msg_send};
1111
use objc2::{Encode, Encoding};

objc2_foundation/src/dictionary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::marker::PhantomData;
44
use core::ops::Index;
55
use core::ptr::{self, NonNull};
66

7-
use objc2::rc::{Id, IdSlice, Owned, Ownership, Shared};
7+
use objc2::rc::{Id, Owned, Ownership, Shared, SliceId};
88
use objc2::runtime::Class;
99
use objc2::{class, msg_send};
1010

0 commit comments

Comments
 (0)