@@ -310,7 +310,7 @@ impl<'a> ToCStr for &'a [u8] {
310
310
let buf = malloc_raw ( self_len + 1 ) ;
311
311
312
312
ptr:: copy_memory ( buf, self . as_ptr ( ) , self_len) ;
313
- * ptr :: mut_offset ( buf, self_len as int ) = 0 ;
313
+ * buf. offset ( self_len as int ) = 0 ;
314
314
315
315
CString :: new ( buf as * libc:: c_char , true )
316
316
}
@@ -368,7 +368,7 @@ impl<'a> Iterator<libc::c_char> for CChars<'a> {
368
368
if ch == 0 {
369
369
None
370
370
} else {
371
- self . ptr = unsafe { ptr :: offset ( self . ptr , 1 ) } ;
371
+ self . ptr = unsafe { self . ptr . offset ( 1 ) } ;
372
372
Some ( ch)
373
373
}
374
374
}
@@ -429,18 +429,18 @@ mod tests {
429
429
fn test_str_to_c_str ( ) {
430
430
"" . to_c_str ( ) . with_ref ( |buf| {
431
431
unsafe {
432
- assert_eq ! ( * ptr :: offset( buf , 0 ) , 0 ) ;
432
+ assert_eq ! ( * buf . offset( 0 ) , 0 ) ;
433
433
}
434
434
} ) ;
435
435
436
436
"hello" . to_c_str ( ) . with_ref ( |buf| {
437
437
unsafe {
438
- assert_eq ! ( * ptr :: offset( buf , 0 ) , 'h' as libc:: c_char) ;
439
- assert_eq ! ( * ptr :: offset( buf , 1 ) , 'e' as libc:: c_char) ;
440
- assert_eq ! ( * ptr :: offset( buf , 2 ) , 'l' as libc:: c_char) ;
441
- assert_eq ! ( * ptr :: offset( buf , 3 ) , 'l' as libc:: c_char) ;
442
- assert_eq ! ( * ptr :: offset( buf , 4 ) , 'o' as libc:: c_char) ;
443
- assert_eq ! ( * ptr :: offset( buf , 5 ) , 0 ) ;
438
+ assert_eq ! ( * buf . offset( 0 ) , 'h' as libc:: c_char) ;
439
+ assert_eq ! ( * buf . offset( 1 ) , 'e' as libc:: c_char) ;
440
+ assert_eq ! ( * buf . offset( 2 ) , 'l' as libc:: c_char) ;
441
+ assert_eq ! ( * buf . offset( 3 ) , 'l' as libc:: c_char) ;
442
+ assert_eq ! ( * buf . offset( 4 ) , 'o' as libc:: c_char) ;
443
+ assert_eq ! ( * buf . offset( 5 ) , 0 ) ;
444
444
}
445
445
} )
446
446
}
@@ -450,28 +450,28 @@ mod tests {
450
450
let b: & [ u8 ] = [ ] ;
451
451
b. to_c_str ( ) . with_ref ( |buf| {
452
452
unsafe {
453
- assert_eq ! ( * ptr :: offset( buf , 0 ) , 0 ) ;
453
+ assert_eq ! ( * buf . offset( 0 ) , 0 ) ;
454
454
}
455
455
} ) ;
456
456
457
457
let _ = bytes ! ( "hello" ) . to_c_str ( ) . with_ref ( |buf| {
458
458
unsafe {
459
- assert_eq ! ( * ptr :: offset( buf , 0 ) , 'h' as libc:: c_char) ;
460
- assert_eq ! ( * ptr :: offset( buf , 1 ) , 'e' as libc:: c_char) ;
461
- assert_eq ! ( * ptr :: offset( buf , 2 ) , 'l' as libc:: c_char) ;
462
- assert_eq ! ( * ptr :: offset( buf , 3 ) , 'l' as libc:: c_char) ;
463
- assert_eq ! ( * ptr :: offset( buf , 4 ) , 'o' as libc:: c_char) ;
464
- assert_eq ! ( * ptr :: offset( buf , 5 ) , 0 ) ;
459
+ assert_eq ! ( * buf . offset( 0 ) , 'h' as libc:: c_char) ;
460
+ assert_eq ! ( * buf . offset( 1 ) , 'e' as libc:: c_char) ;
461
+ assert_eq ! ( * buf . offset( 2 ) , 'l' as libc:: c_char) ;
462
+ assert_eq ! ( * buf . offset( 3 ) , 'l' as libc:: c_char) ;
463
+ assert_eq ! ( * buf . offset( 4 ) , 'o' as libc:: c_char) ;
464
+ assert_eq ! ( * buf . offset( 5 ) , 0 ) ;
465
465
}
466
466
} ) ;
467
467
468
468
let _ = bytes ! ( "foo" , 0xff ) . to_c_str ( ) . with_ref ( |buf| {
469
469
unsafe {
470
- assert_eq ! ( * ptr :: offset( buf , 0 ) , 'f' as libc:: c_char) ;
471
- assert_eq ! ( * ptr :: offset( buf , 1 ) , 'o' as libc:: c_char) ;
472
- assert_eq ! ( * ptr :: offset( buf , 2 ) , 'o' as libc:: c_char) ;
473
- assert_eq ! ( * ptr :: offset( buf , 3 ) , 0xff as i8 ) ;
474
- assert_eq ! ( * ptr :: offset( buf , 4 ) , 0 ) ;
470
+ assert_eq ! ( * buf . offset( 0 ) , 'f' as libc:: c_char) ;
471
+ assert_eq ! ( * buf . offset( 1 ) , 'o' as libc:: c_char) ;
472
+ assert_eq ! ( * buf . offset( 2 ) , 'o' as libc:: c_char) ;
473
+ assert_eq ! ( * buf . offset( 3 ) , 0xff as i8 ) ;
474
+ assert_eq ! ( * buf . offset( 4 ) , 0 ) ;
475
475
}
476
476
} ) ;
477
477
}
@@ -634,16 +634,15 @@ mod bench {
634
634
use extra:: test:: BenchHarness ;
635
635
use libc;
636
636
use prelude:: * ;
637
- use ptr;
638
637
639
638
#[ inline]
640
639
fn check ( s : & str , c_str : * libc:: c_char ) {
641
640
let s_buf = s. as_ptr ( ) ;
642
641
for i in range ( 0 , s. len ( ) ) {
643
642
unsafe {
644
643
assert_eq ! (
645
- * ptr :: offset( s_buf , i as int) as libc:: c_char,
646
- * ptr :: offset( c_str , i as int) ) ;
644
+ * s_buf . offset( i as int) as libc:: c_char,
645
+ * c_str . offset( i as int) ) ;
647
646
}
648
647
}
649
648
}
0 commit comments