@@ -360,13 +360,17 @@ rem_float_impl! { f64, fmod }
360
360
/// `neg`, and therefore, `main` prints `Negating!`.
361
361
///
362
362
/// ```
363
+ /// #![feature(associated_types)]
364
+ ///
363
365
/// use std::ops::Neg;
364
366
///
365
367
/// struct Foo;
366
368
///
367
369
/// impl Copy for Foo {}
368
370
///
369
- /// impl Neg<Foo> for Foo {
371
+ /// impl Neg for Foo {
372
+ /// type Output = Foo;
373
+ ///
370
374
/// fn neg(self) -> Foo {
371
375
/// println!("Negating!");
372
376
/// self
@@ -378,14 +382,18 @@ rem_float_impl! { f64, fmod }
378
382
/// }
379
383
/// ```
380
384
#[ lang="neg" ]
381
- pub trait Neg < Result > {
385
+ pub trait Neg {
386
+ type Output ;
387
+
382
388
/// The method for the unary `-` operator
383
- fn neg ( self ) -> Result ;
389
+ fn neg ( self ) -> Self :: Output ;
384
390
}
385
391
386
392
macro_rules! neg_impl {
387
393
( $( $t: ty) * ) => ( $(
388
- impl Neg <$t> for $t {
394
+ impl Neg for $t {
395
+ type Output = $t;
396
+
389
397
#[ inline]
390
398
fn neg( self ) -> $t { -self }
391
399
}
@@ -394,7 +402,9 @@ macro_rules! neg_impl {
394
402
395
403
macro_rules! neg_uint_impl {
396
404
( $t: ty, $t_signed: ty) => {
397
- impl Neg <$t> for $t {
405
+ impl Neg for $t {
406
+ type Output = $t;
407
+
398
408
#[ inline]
399
409
fn neg( self ) -> $t { -( self as $t_signed) as $t }
400
410
}
@@ -418,13 +428,17 @@ neg_uint_impl! { u64, i64 }
418
428
/// `not`, and therefore, `main` prints `Not-ing!`.
419
429
///
420
430
/// ```
431
+ /// #![feature(associated_types)]
432
+ ///
421
433
/// use std::ops::Not;
422
434
///
423
435
/// struct Foo;
424
436
///
425
437
/// impl Copy for Foo {}
426
438
///
427
- /// impl Not<Foo> for Foo {
439
+ /// impl Not for Foo {
440
+ /// type Output = Foo;
441
+ ///
428
442
/// fn not(self) -> Foo {
429
443
/// println!("Not-ing!");
430
444
/// self
@@ -436,14 +450,18 @@ neg_uint_impl! { u64, i64 }
436
450
/// }
437
451
/// ```
438
452
#[ lang="not" ]
439
- pub trait Not < Result > {
453
+ pub trait Not {
454
+ type Output ;
455
+
440
456
/// The method for the unary `!` operator
441
- fn not ( self ) -> Result ;
457
+ fn not ( self ) -> Self :: Output ;
442
458
}
443
459
444
460
macro_rules! not_impl {
445
461
( $( $t: ty) * ) => ( $(
446
- impl Not <$t> for $t {
462
+ impl Not for $t {
463
+ type Output = $t;
464
+
447
465
#[ inline]
448
466
fn not( self ) -> $t { !self }
449
467
}
0 commit comments