Skip to content

Commit 897c0a3

Browse files
authored
More Copy arguments (#2654)
1 parent 3391fb8 commit 897c0a3

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

components/timezone/src/time_zone.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ impl FromStr for CustomTimeZone {
148148
/// let tz3: CustomTimeZone =
149149
/// "+02:30".parse().expect("Failed to parse a time zone.");
150150
///
151-
/// assert_eq!(tz0.gmt_offset.as_ref().map(GmtOffset::offset_seconds), Some(0));
152-
/// assert_eq!(tz1.gmt_offset.as_ref().map(GmtOffset::offset_seconds), Some(7200));
153-
/// assert_eq!(tz2.gmt_offset.as_ref().map(GmtOffset::offset_seconds), Some(-9000));
154-
/// assert_eq!(tz3.gmt_offset.as_ref().map(GmtOffset::offset_seconds), Some(9000));
151+
/// assert_eq!(tz0.gmt_offset.map(GmtOffset::offset_seconds), Some(0));
152+
/// assert_eq!(tz1.gmt_offset.map(GmtOffset::offset_seconds), Some(7200));
153+
/// assert_eq!(tz2.gmt_offset.map(GmtOffset::offset_seconds), Some(-9000));
154+
/// assert_eq!(tz3.gmt_offset.map(GmtOffset::offset_seconds), Some(9000));
155155
/// ```
156156
fn from_str(input: &str) -> Result<Self, Self::Err> {
157157
let gmt_offset = input.parse::<GmtOffset>()?;

components/timezone/src/types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,27 @@ impl GmtOffset {
4646
}
4747

4848
/// Returns the raw offset value in seconds.
49-
pub fn offset_seconds(&self) -> i32 {
49+
pub fn offset_seconds(self) -> i32 {
5050
self.0
5151
}
5252

5353
/// Returns `true` if the [`GmtOffset`] is positive, otherwise `false`.
54-
pub fn is_positive(&self) -> bool {
54+
pub fn is_positive(self) -> bool {
5555
self.0 >= 0
5656
}
5757

5858
/// Returns `true` if the [`GmtOffset`] is zero, otherwise `false`.
59-
pub fn is_zero(&self) -> bool {
59+
pub fn is_zero(self) -> bool {
6060
self.0 == 0
6161
}
6262

6363
/// Returns `true` if the [`GmtOffset`] has non-zero minutes, otherwise `false`.
64-
pub fn has_minutes(&self) -> bool {
64+
pub fn has_minutes(self) -> bool {
6565
self.0 % 3600 / 60 > 0
6666
}
6767

6868
/// Returns `true` if the [`GmtOffset`] has non-zero seconds, otherwise `false`.
69-
pub fn has_seconds(&self) -> bool {
69+
pub fn has_seconds(self) -> bool {
7070
self.0 % 3600 % 60 > 0
7171
}
7272
}

provider/core/src/key.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ macro_rules! tagged {
4949
pub struct DataKeyHash([u8; 4]);
5050

5151
impl DataKeyHash {
52-
const fn compute_from_path(path: &DataKeyPath) -> Self {
52+
const fn compute_from_path(path: DataKeyPath) -> Self {
5353
let hash = helpers::fxhash_32(
5454
path.tagged.as_bytes(),
5555
leading_tag!().len(),
@@ -59,7 +59,7 @@ impl DataKeyHash {
5959
}
6060

6161
/// Gets the hash value as a byte array.
62-
pub const fn to_bytes(&self) -> [u8; 4] {
62+
pub const fn to_bytes(self) -> [u8; 4] {
6363
self.0
6464
}
6565
}
@@ -139,7 +139,7 @@ pub struct DataKeyPath {
139139
impl DataKeyPath {
140140
/// Gets the path as a static string slice.
141141
#[inline]
142-
pub const fn get(&self) -> &'static str {
142+
pub const fn get(self) -> &'static str {
143143
/// core::slice::from_raw_parts(a, b) = core::mem::transmute((a, b)) hack
144144
/// ```compile_fail
145145
/// const unsafe fn canary() { core::slice::from_raw_parts(0 as *const u8, 0); }
@@ -277,7 +277,7 @@ impl DataKey {
277277
///
278278
/// Useful for reading and writing data to a file system.
279279
#[inline]
280-
pub const fn path(&self) -> DataKeyPath {
280+
pub const fn path(self) -> DataKeyPath {
281281
self.path
282282
}
283283

@@ -297,13 +297,13 @@ impl DataKey {
297297
/// assert_eq!(KEY_HASH.to_bytes(), [0xe2, 0xb6, 0x17, 0x71]);
298298
/// ```
299299
#[inline]
300-
pub const fn hashed(&self) -> DataKeyHash {
300+
pub const fn hashed(self) -> DataKeyHash {
301301
self.hash
302302
}
303303

304304
/// Gets the metadata associated with this [`DataKey`].
305305
#[inline]
306-
pub const fn metadata(&self) -> DataKeyMetadata {
306+
pub const fn metadata(self) -> DataKeyMetadata {
307307
self.metadata
308308
}
309309

@@ -328,7 +328,7 @@ impl DataKey {
328328
pub const fn from_path_and_metadata(path: DataKeyPath, metadata: DataKeyMetadata) -> Self {
329329
Self {
330330
path,
331-
hash: DataKeyHash::compute_from_path(&path),
331+
hash: DataKeyHash::compute_from_path(path),
332332
metadata,
333333
}
334334
}
@@ -373,7 +373,7 @@ impl DataKey {
373373

374374
Ok(Self {
375375
path,
376-
hash: DataKeyHash::compute_from_path(&path),
376+
hash: DataKeyHash::compute_from_path(path),
377377
metadata,
378378
})
379379
}
@@ -453,8 +453,8 @@ impl DataKey {
453453
/// // The error context contains the argument:
454454
/// assert_eq!(FOO_BAR.match_key(BAR_BAZ).unwrap_err().key, Some(BAR_BAZ));
455455
/// ```
456-
pub fn match_key(&self, key: Self) -> Result<(), DataError> {
457-
if *self == key {
456+
pub fn match_key(self, key: Self) -> Result<(), DataError> {
457+
if self == key {
458458
Ok(())
459459
} else {
460460
Err(DataErrorKind::MissingDataKey.with_key(key))

0 commit comments

Comments
 (0)