Skip to content

Commit a7c7273

Browse files
committed
core: Convert Char methods to by-val self
Methods on primitmive Copy types generally should take `self`. [breaking-change]
1 parent ddbd4e0 commit a7c7273

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/libcore/char.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub trait Char {
209209
///
210210
/// Fails if given a radix > 36.
211211
#[deprecated = "use is_digit"]
212-
fn is_digit_radix(&self, radix: uint) -> bool;
212+
fn is_digit_radix(self, radix: uint) -> bool;
213213

214214
/// Checks if a `char` parses as a numeric digit in the given radix.
215215
///
@@ -225,7 +225,7 @@ pub trait Char {
225225
///
226226
/// Fails if given a radix > 36.
227227
#[unstable = "pending error conventions"]
228-
fn is_digit(&self, radix: uint) -> bool;
228+
fn is_digit(self, radix: uint) -> bool;
229229

230230
/// Converts a character to the corresponding digit.
231231
///
@@ -239,7 +239,7 @@ pub trait Char {
239239
///
240240
/// Fails if given a radix outside the range [0..36].
241241
#[unstable = "pending error conventions, trait organization"]
242-
fn to_digit(&self, radix: uint) -> Option<uint>;
242+
fn to_digit(self, radix: uint) -> Option<uint>;
243243

244244
/// Converts a number to the character representing it.
245245
///
@@ -266,7 +266,7 @@ pub trait Char {
266266
/// * Characters in [0x100,0xffff] get 4-digit escapes: `\\uNNNN`.
267267
/// * Characters above 0x10000 get 8-digit escapes: `\\UNNNNNNNN`.
268268
#[unstable = "pending error conventions, trait organization"]
269-
fn escape_unicode(&self, f: |char|);
269+
fn escape_unicode(self, f: |char|);
270270

271271
/// Returns a 'default' ASCII and C++11-like literal escape of a
272272
/// character.
@@ -281,22 +281,22 @@ pub trait Char {
281281
/// * Any other chars in the range [0x20,0x7e] are not escaped.
282282
/// * Any other chars are given hex Unicode escapes; see `escape_unicode`.
283283
#[unstable = "pending error conventions, trait organization"]
284-
fn escape_default(&self, f: |char|);
284+
fn escape_default(self, f: |char|);
285285

286286
/// Returns the amount of bytes this character would need if encoded in
287287
/// UTF-8.
288288
#[deprecated = "use len_utf8"]
289-
fn len_utf8_bytes(&self) -> uint;
289+
fn len_utf8_bytes(self) -> uint;
290290

291291
/// Returns the amount of bytes this character would need if encoded in
292292
/// UTF-8.
293293
#[unstable = "pending trait organization"]
294-
fn len_utf8(&self) -> uint;
294+
fn len_utf8(self) -> uint;
295295

296296
/// Returns the amount of bytes this character would need if encoded in
297297
/// UTF-16.
298298
#[unstable = "pending trait organization"]
299-
fn len_utf16(&self) -> uint;
299+
fn len_utf16(self) -> uint;
300300

301301
/// Encodes this character as UTF-8 into the provided byte buffer,
302302
/// and then returns the number of bytes written.
@@ -318,25 +318,25 @@ pub trait Char {
318318
#[experimental = "trait is experimental"]
319319
impl Char for char {
320320
#[deprecated = "use is_digit"]
321-
fn is_digit_radix(&self, radix: uint) -> bool { self.is_digit(radix) }
321+
fn is_digit_radix(self, radix: uint) -> bool { self.is_digit(radix) }
322322

323323
#[unstable = "pending trait organization"]
324-
fn is_digit(&self, radix: uint) -> bool {
324+
fn is_digit(self, radix: uint) -> bool {
325325
match self.to_digit(radix) {
326326
Some(_) => true,
327327
None => false,
328328
}
329329
}
330330

331331
#[unstable = "pending trait organization"]
332-
fn to_digit(&self, radix: uint) -> Option<uint> {
332+
fn to_digit(self, radix: uint) -> Option<uint> {
333333
if radix > 36 {
334334
panic!("to_digit: radix is too high (maximum 36)");
335335
}
336-
let val = match *self {
337-
'0' ... '9' => *self as uint - ('0' as uint),
338-
'a' ... 'z' => *self as uint + 10u - ('a' as uint),
339-
'A' ... 'Z' => *self as uint + 10u - ('A' as uint),
336+
let val = match self {
337+
'0' ... '9' => self as uint - ('0' as uint),
338+
'a' ... 'z' => self as uint + 10u - ('a' as uint),
339+
'A' ... 'Z' => self as uint + 10u - ('A' as uint),
340340
_ => return None,
341341
};
342342
if val < radix { Some(val) }
@@ -351,19 +351,19 @@ impl Char for char {
351351
fn from_u32(i: u32) -> Option<char> { from_u32(i) }
352352

353353
#[unstable = "pending error conventions, trait organization"]
354-
fn escape_unicode(&self, f: |char|) {
354+
fn escape_unicode(self, f: |char|) {
355355
// avoid calling str::to_str_radix because we don't really need to allocate
356356
// here.
357357
f('\\');
358358
let pad = match () {
359-
_ if *self <= '\xff' => { f('x'); 2 }
360-
_ if *self <= '\uffff' => { f('u'); 4 }
359+
_ if self <= '\xff' => { f('x'); 2 }
360+
_ if self <= '\uffff' => { f('u'); 4 }
361361
_ => { f('U'); 8 }
362362
};
363363
for offset in range_step::<i32>(4 * (pad - 1), -1, -4) {
364364
let offset = offset as uint;
365365
unsafe {
366-
match ((*self as i32) >> offset) & 0xf {
366+
match ((self as i32) >> offset) & 0xf {
367367
i @ 0 ... 9 => { f(transmute('0' as i32 + i)); }
368368
i => { f(transmute('a' as i32 + (i - 10))); }
369369
}
@@ -372,27 +372,27 @@ impl Char for char {
372372
}
373373

374374
#[unstable = "pending error conventions, trait organization"]
375-
fn escape_default(&self, f: |char|) {
376-
match *self {
375+
fn escape_default(self, f: |char|) {
376+
match self {
377377
'\t' => { f('\\'); f('t'); }
378378
'\r' => { f('\\'); f('r'); }
379379
'\n' => { f('\\'); f('n'); }
380380
'\\' => { f('\\'); f('\\'); }
381381
'\'' => { f('\\'); f('\''); }
382382
'"' => { f('\\'); f('"'); }
383-
'\x20' ... '\x7e' => { f(*self); }
383+
'\x20' ... '\x7e' => { f(self); }
384384
_ => self.escape_unicode(f),
385385
}
386386
}
387387

388388
#[inline]
389389
#[deprecated = "use len_utf8"]
390-
fn len_utf8_bytes(&self) -> uint { self.len_utf8() }
390+
fn len_utf8_bytes(self) -> uint { self.len_utf8() }
391391

392392
#[inline]
393393
#[unstable = "pending trait organization"]
394-
fn len_utf8(&self) -> uint {
395-
let code = *self as u32;
394+
fn len_utf8(self) -> uint {
395+
let code = self as u32;
396396
match () {
397397
_ if code < MAX_ONE_B => 1u,
398398
_ if code < MAX_TWO_B => 2u,
@@ -403,8 +403,8 @@ impl Char for char {
403403

404404
#[inline]
405405
#[unstable = "pending trait organization"]
406-
fn len_utf16(&self) -> uint {
407-
let ch = *self as u32;
406+
fn len_utf16(self) -> uint {
407+
let ch = self as u32;
408408
if (ch & 0xFFFF_u32) == ch { 1 } else { 2 }
409409
}
410410

0 commit comments

Comments
 (0)