diff options
| author | varkor <github@varkor.com> | 2018-04-24 21:56:57 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-04-25 11:26:47 +0100 |
| commit | 6805e5abd2a6fbdca75ff3c96ee58398dcbdfd04 (patch) | |
| tree | 8564a87d912a670629b7f319a160d4053a88dbf5 /src/libsyntax_ext | |
| parent | 98e3e82ecea8b3b2100362e6fa87dc76779855bc (diff) | |
| download | rust-6805e5abd2a6fbdca75ff3c96ee58398dcbdfd04.tar.gz rust-6805e5abd2a6fbdca75ff3c96ee58398dcbdfd04.zip | |
Update comments to UFCS style
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/deriving/cmp/partial_ord.rs | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/libsyntax_ext/deriving/cmp/partial_ord.rs b/src/libsyntax_ext/deriving/cmp/partial_ord.rs index f8c27bf42a9..2b3930063f3 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_ord.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_ord.rs @@ -14,7 +14,7 @@ use deriving::{path_local, pathvec_std, path_std}; use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast::{self, BinOpKind, Expr, MetaItem, Ident}; +use syntax::ast::{self, BinOpKind, Expr, MetaItem}; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; @@ -231,8 +231,14 @@ fn cs_op(less: bool, // `ast::lt` // // ``` - // self.f1.partial_cmp(other.f1).unwrap_or(Ordering::Equal) - // .then_with(|| self.f2.partial_cmp(other.f2).unwrap_or(Ordering::Equal)) + // Ordering::then_with( + // Option::unwrap_or( + // PartialOrd::partial_cmp(self.f1, other.f1), Ordering::Equal) + // ), + // Option::unwrap_or( + // PartialOrd::partial_cmp(self.f2, other.f2), Ordering::Greater) + // ) + // ) // == Ordering::Less // ``` // @@ -240,8 +246,14 @@ fn cs_op(less: bool, // `ast::le` // // ``` - // self.f1.partial_cmp(other.f1).unwrap_or(Ordering::Equal) - // .then_with(|| self.f2.partial_cmp(other.f2).unwrap_or(Ordering::Equal)) + // Ordering::then_with( + // Option::unwrap_or( + // PartialOrd::partial_cmp(self.f1, other.f1), Ordering::Equal) + // ), + // Option::unwrap_or( + // PartialOrd::partial_cmp(self.f2, other.f2), Ordering::Greater) + // ) + // ) // != Ordering::Greater // ``` // @@ -249,14 +261,15 @@ fn cs_op(less: bool, // get use the binops to avoid auto-deref dereferencing too many // layers of pointers, if the type includes pointers. - // `self.fi.partial_cmp(other.fi).unwrap_or(Ordering::Equal)` + // `Option::unwrap_or(PartialOrd::partial_cmp(self.fi, other.fi), Ordering::Equal)` let par_cmp = par_cmp(cx, span, self_f, other_fs, "Equal"); - // `self.fi.partial_cmp(other.fi).unwrap_or(Ordering::Equal).then_with(...)` - cx.expr_method_call(span, - par_cmp, - Ident::from_str("then_with"), - vec![cx.lambda0(span, subexpr)]) + // `Ordering::then_with(Option::unwrap_or(..), ..)` + let then_with_path = cx.expr_path(cx.path_global(span, + cx.std_path(&["cmp", + "Ordering", + "then_with"]))); + cx.expr_call(span, then_with_path, vec![par_cmp, cx.lambda0(span, subexpr)]) }, |cx, args| { match args { |
