Rustfmt
diff --git a/src/aster/generics.rs b/src/aster/generics.rs
index c3c4846..8feb87c 100644
--- a/src/aster/generics.rs
+++ b/src/aster/generics.rs
@@ -1,18 +1,11 @@
-use {
- Generics,
- Ident,
- LifetimeDef,
- TyParam,
- WhereClause,
- WherePredicate,
-};
+use {Generics, Ident, LifetimeDef, TyParam, WhereClause, WherePredicate};
use aster::invoke::{Identity, Invoke};
use aster::lifetime::{IntoLifetime, LifetimeDefBuilder, IntoLifetimeDef};
use aster::path::IntoPath;
use aster::ty_param::TyParamBuilder;
use aster::where_predicate::WherePredicateBuilder;
-pub struct GenericsBuilder<F=Identity> {
+pub struct GenericsBuilder<F = Identity> {
callback: F,
lifetimes: Vec<LifetimeDef>,
ty_params: Vec<TyParam>,
@@ -30,7 +23,7 @@
}
impl<F> GenericsBuilder<F>
- where F: Invoke<Generics>,
+ where F: Invoke<Generics>
{
pub fn with_callback(callback: F) -> Self {
GenericsBuilder {
@@ -57,8 +50,8 @@
}
pub fn with_lifetimes<I, L>(mut self, iter: I) -> Self
- where I: IntoIterator<Item=L>,
- L: IntoLifetimeDef,
+ where I: IntoIterator<Item = L>,
+ L: IntoLifetimeDef
{
let iter = iter.into_iter().map(|lifetime_def| lifetime_def.into_lifetime_def());
self.lifetimes.extend(iter);
@@ -66,8 +59,8 @@
}
pub fn with_lifetime_names<I, N>(mut self, iter: I) -> Self
- where I: IntoIterator<Item=N>,
- N: Into<Ident>,
+ where I: IntoIterator<Item = N>,
+ N: Into<Ident>
{
for name in iter {
self = self.lifetime_name(name);
@@ -81,27 +74,27 @@
}
pub fn lifetime_name<N>(self, name: N) -> Self
- where N: Into<Ident>,
+ where N: Into<Ident>
{
self.lifetime(name).build()
}
pub fn lifetime<N>(self, name: N) -> LifetimeDefBuilder<Self>
- where N: Into<Ident>,
+ where N: Into<Ident>
{
LifetimeDefBuilder::with_callback(name, self)
}
pub fn with_ty_params<I>(mut self, iter: I) -> Self
- where I: IntoIterator<Item=TyParam>,
+ where I: IntoIterator<Item = TyParam>
{
self.ty_params.extend(iter);
self
}
pub fn with_ty_param_ids<I, T>(mut self, iter: I) -> Self
- where I: IntoIterator<Item=T>,
- T: Into<Ident>,
+ where I: IntoIterator<Item = T>,
+ T: Into<Ident>
{
for id in iter {
self = self.ty_param_id(id);
@@ -115,19 +108,19 @@
}
pub fn ty_param_id<I>(self, id: I) -> Self
- where I: Into<Ident>,
+ where I: Into<Ident>
{
self.ty_param(id).build()
}
pub fn ty_param<I>(self, id: I) -> TyParamBuilder<Self>
- where I: Into<Ident>,
+ where I: Into<Ident>
{
TyParamBuilder::with_callback(id, self)
}
pub fn with_predicates<I>(mut self, iter: I) -> Self
- where I: IntoIterator<Item=WherePredicate>,
+ where I: IntoIterator<Item = WherePredicate>
{
self.predicates.extend(iter);
self
@@ -143,7 +136,7 @@
}
pub fn add_lifetime_bound<L>(mut self, lifetime: L) -> Self
- where L: IntoLifetime,
+ where L: IntoLifetime
{
let lifetime = lifetime.into_lifetime();
@@ -161,13 +154,14 @@
}
pub fn add_ty_param_bound<P>(mut self, path: P) -> Self
- where P: IntoPath,
+ where P: IntoPath
{
let path = path.into_path();
for ty_param in &mut self.ty_params {
*ty_param = TyParamBuilder::from_ty_param(ty_param.clone())
- .trait_bound(path.clone()).build()
+ .trait_bound(path.clone())
+ .build()
.build();
}
@@ -203,15 +197,13 @@
self.callback.invoke(Generics {
lifetimes: self.lifetimes,
ty_params: self.ty_params,
- where_clause: WhereClause {
- predicates: self.predicates,
- },
+ where_clause: WhereClause { predicates: self.predicates },
})
}
}
impl<F> Invoke<LifetimeDef> for GenericsBuilder<F>
- where F: Invoke<Generics>,
+ where F: Invoke<Generics>
{
type Result = Self;
@@ -221,7 +213,7 @@
}
impl<F> Invoke<TyParam> for GenericsBuilder<F>
- where F: Invoke<Generics>,
+ where F: Invoke<Generics>
{
type Result = Self;
@@ -231,7 +223,7 @@
}
impl<F> Invoke<WherePredicate> for GenericsBuilder<F>
- where F: Invoke<Generics>,
+ where F: Invoke<Generics>
{
type Result = Self;
diff --git a/src/aster/ident.rs b/src/aster/ident.rs
index 586e471..0c2473f 100644
--- a/src/aster/ident.rs
+++ b/src/aster/ident.rs
@@ -22,13 +22,17 @@
}
}
-impl<'a, T> ToIdent for &'a T where T: ToIdent {
+impl<'a, T> ToIdent for &'a T
+ where T: ToIdent
+{
fn to_ident(&self) -> Ident {
(**self).to_ident()
}
}
-impl<'a, T> ToIdent for &'a mut T where T: ToIdent {
+impl<'a, T> ToIdent for &'a mut T
+ where T: ToIdent
+{
fn to_ident(&self) -> Ident {
(**self).to_ident()
}
diff --git a/src/aster/invoke.rs b/src/aster/invoke.rs
index cf799e2..76ae967 100644
--- a/src/aster/invoke.rs
+++ b/src/aster/invoke.rs
@@ -10,5 +10,7 @@
impl<A> Invoke<A> for Identity {
type Result = A;
- fn invoke(self, arg: A) -> A { arg }
+ fn invoke(self, arg: A) -> A {
+ arg
+ }
}
diff --git a/src/aster/lifetime.rs b/src/aster/lifetime.rs
index 517aff5..5f0d8c4 100644
--- a/src/aster/lifetime.rs
+++ b/src/aster/lifetime.rs
@@ -1,11 +1,7 @@
-use {
- Ident,
- Lifetime,
- LifetimeDef,
-};
+use {Ident, Lifetime, LifetimeDef};
use aster::invoke::{Invoke, Identity};
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub trait IntoLifetime {
fn into_lifetime(self) -> Lifetime;
@@ -19,13 +15,11 @@
impl<'a> IntoLifetime for &'a str {
fn into_lifetime(self) -> Lifetime {
- Lifetime {
- ident: self.into(),
- }
+ Lifetime { ident: self.into() }
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub trait IntoLifetimeDef {
fn into_lifetime_def(self) -> LifetimeDef;
@@ -58,9 +52,9 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
-pub struct LifetimeDefBuilder<F=Identity> {
+pub struct LifetimeDefBuilder<F = Identity> {
callback: F,
lifetime: Lifetime,
bounds: Vec<Lifetime>,
@@ -68,21 +62,19 @@
impl LifetimeDefBuilder {
pub fn new<N>(name: N) -> Self
- where N: Into<Ident>,
+ where N: Into<Ident>
{
LifetimeDefBuilder::with_callback(name, Identity)
}
}
impl<F> LifetimeDefBuilder<F>
- where F: Invoke<LifetimeDef>,
+ where F: Invoke<LifetimeDef>
{
pub fn with_callback<N>(name: N, callback: F) -> Self
- where N: Into<Ident>,
+ where N: Into<Ident>
{
- let lifetime = Lifetime {
- ident: name.into(),
- };
+ let lifetime = Lifetime { ident: name.into() };
LifetimeDefBuilder {
callback: callback,
@@ -92,11 +84,9 @@
}
pub fn bound<N>(mut self, name: N) -> Self
- where N: Into<Ident>,
+ where N: Into<Ident>
{
- let lifetime = Lifetime {
- ident: name.into(),
- };
+ let lifetime = Lifetime { ident: name.into() };
self.bounds.push(lifetime);
self
diff --git a/src/aster/path.rs b/src/aster/path.rs
index 14695e0..a0fb314 100644
--- a/src/aster/path.rs
+++ b/src/aster/path.rs
@@ -1,21 +1,11 @@
-use {
- AngleBracketedParameterData,
- Generics,
- Ident,
- Lifetime,
- ParenthesizedParameterData,
- Path,
- PathParameters,
- PathSegment,
- Ty,
- TypeBinding,
-};
+use {AngleBracketedParameterData, Generics, Ident, Lifetime, ParenthesizedParameterData, Path,
+ PathParameters, PathSegment, Ty, TypeBinding};
use aster::ident::ToIdent;
use aster::invoke::{Invoke, Identity};
use aster::lifetime::IntoLifetime;
use aster::ty::TyBuilder;
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub trait IntoPath {
fn into_path(self) -> Path;
@@ -45,15 +35,17 @@
}
}
-impl<'a, T> IntoPath for &'a [T] where T: ToIdent {
+impl<'a, T> IntoPath for &'a [T]
+ where T: ToIdent
+{
fn into_path(self) -> Path {
PathBuilder::new().ids(self).build()
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
-pub struct PathBuilder<F=Identity> {
+pub struct PathBuilder<F = Identity> {
callback: F,
global: bool,
}
@@ -65,7 +57,7 @@
}
impl<F> PathBuilder<F>
- where F: Invoke<Path>,
+ where F: Invoke<Path>
{
pub fn with_callback(callback: F) -> Self {
PathBuilder {
@@ -84,8 +76,8 @@
}
pub fn ids<I, T>(self, ids: I) -> PathSegmentsBuilder<F>
- where I: IntoIterator<Item=T>,
- T: ToIdent,
+ where I: IntoIterator<Item = T>,
+ T: ToIdent
{
let mut ids = ids.into_iter();
let id = ids.next().expect("passed path with no id");
@@ -94,37 +86,37 @@
}
pub fn id<I>(self, id: I) -> PathSegmentsBuilder<F>
- where I: ToIdent,
+ where I: ToIdent
{
self.segment(id).build()
}
- pub fn segment<I>(self, id: I)
- -> PathSegmentBuilder<PathSegmentsBuilder<F>>
- where I: ToIdent,
+ pub fn segment<I>(self, id: I) -> PathSegmentBuilder<PathSegmentsBuilder<F>>
+ where I: ToIdent
{
- PathSegmentBuilder::with_callback(id, PathSegmentsBuilder {
- callback: self.callback,
- global: self.global,
- segments: Vec::new(),
- })
+ PathSegmentBuilder::with_callback(id,
+ PathSegmentsBuilder {
+ callback: self.callback,
+ global: self.global,
+ segments: Vec::new(),
+ })
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
-pub struct PathSegmentsBuilder<F=Identity> {
+pub struct PathSegmentsBuilder<F = Identity> {
callback: F,
global: bool,
segments: Vec<PathSegment>,
}
impl<F> PathSegmentsBuilder<F>
- where F: Invoke<Path>,
+ where F: Invoke<Path>
{
pub fn ids<I, T>(mut self, ids: I) -> PathSegmentsBuilder<F>
- where I: IntoIterator<Item=T>,
- T: ToIdent,
+ where I: IntoIterator<Item = T>,
+ T: ToIdent
{
for id in ids {
self = self.id(id);
@@ -134,13 +126,13 @@
}
pub fn id<T>(self, id: T) -> PathSegmentsBuilder<F>
- where T: ToIdent,
+ where T: ToIdent
{
self.segment(id).build()
}
pub fn segment<T>(self, id: T) -> PathSegmentBuilder<Self>
- where T: ToIdent,
+ where T: ToIdent
{
PathSegmentBuilder::with_callback(id, self)
}
@@ -162,9 +154,9 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
-pub struct PathSegmentBuilder<F=Identity> {
+pub struct PathSegmentBuilder<F = Identity> {
callback: F,
id: Ident,
lifetimes: Vec<Lifetime>,
@@ -173,10 +165,10 @@
}
impl<F> PathSegmentBuilder<F>
- where F: Invoke<PathSegment>,
+ where F: Invoke<PathSegment>
{
pub fn with_callback<I>(id: I, callback: F) -> Self
- where I: ToIdent,
+ where I: ToIdent
{
PathSegmentBuilder {
callback: callback,
@@ -189,10 +181,12 @@
pub fn with_generics(self, generics: Generics) -> Self {
// Strip off the bounds.
- let lifetimes = generics.lifetimes.iter()
+ let lifetimes = generics.lifetimes
+ .iter()
.map(|lifetime_def| lifetime_def.lifetime.clone());
- let tys = generics.ty_params.iter()
+ let tys = generics.ty_params
+ .iter()
.map(|ty_param| TyBuilder::new().id(ty_param.ident.clone()));
self.with_lifetimes(lifetimes)
@@ -200,8 +194,8 @@
}
pub fn with_lifetimes<I, L>(mut self, iter: I) -> Self
- where I: IntoIterator<Item=L>,
- L: IntoLifetime,
+ where I: IntoIterator<Item = L>,
+ L: IntoLifetime
{
let iter = iter.into_iter().map(|lifetime| lifetime.into_lifetime());
self.lifetimes.extend(iter);
@@ -209,23 +203,21 @@
}
pub fn with_lifetime<L>(mut self, lifetime: L) -> Self
- where L: IntoLifetime,
+ where L: IntoLifetime
{
self.lifetimes.push(lifetime.into_lifetime());
self
}
pub fn lifetime<N>(self, name: N) -> Self
- where N: ToIdent,
+ where N: ToIdent
{
- let lifetime = Lifetime {
- ident: name.to_ident(),
- };
+ let lifetime = Lifetime { ident: name.to_ident() };
self.with_lifetime(lifetime)
}
pub fn with_tys<I>(mut self, iter: I) -> Self
- where I: IntoIterator<Item=Ty>,
+ where I: IntoIterator<Item = Ty>
{
self.tys.extend(iter);
self
@@ -246,7 +238,7 @@
}
pub fn binding<T>(self, id: T) -> TyBuilder<TypeBindingBuilder<F>>
- where T: ToIdent,
+ where T: ToIdent
{
TyBuilder::with_callback(TypeBindingBuilder {
id: id.to_ident(),
@@ -302,7 +294,7 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TypeBindingBuilder<F> {
id: Ident,
@@ -324,7 +316,7 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct PathSegmentReturnBuilder<F>(PathSegmentBuilder<F>);
diff --git a/src/aster/qpath.rs b/src/aster/qpath.rs
index ab2516e..71f68b1 100644
--- a/src/aster/qpath.rs
+++ b/src/aster/qpath.rs
@@ -1,17 +1,12 @@
-use {
- Path,
- PathSegment,
- QSelf,
- Ty,
-};
+use {Path, PathSegment, QSelf, Ty};
use aster::ident::ToIdent;
use aster::invoke::{Invoke, Identity};
use aster::path::{PathBuilder, PathSegmentBuilder};
use aster::ty::TyBuilder;
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
-pub struct QPathBuilder<F=Identity> {
+pub struct QPathBuilder<F = Identity> {
callback: F,
}
@@ -22,14 +17,12 @@
}
impl<F> QPathBuilder<F>
- where F: Invoke<(QSelf, Path)>,
+ where F: Invoke<(QSelf, Path)>
{
/// Construct a `QPathBuilder` that will call the `callback` with a constructed `QSelf`
/// and `Path`.
pub fn with_callback(callback: F) -> Self {
- QPathBuilder {
- callback: callback,
- }
+ QPathBuilder { callback: callback }
}
/// Build a qualified path first by starting with a type builder.
@@ -52,7 +45,7 @@
}
impl<F> Invoke<Ty> for QPathBuilder<F>
- where F: Invoke<(QSelf, Path)>,
+ where F: Invoke<(QSelf, Path)>
{
type Result = QPathTyBuilder<F>;
@@ -61,7 +54,7 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct QPathTyBuilder<F> {
builder: QPathBuilder<F>,
@@ -69,7 +62,7 @@
}
impl<F> QPathTyBuilder<F>
- where F: Invoke<(QSelf, Path)>,
+ where F: Invoke<(QSelf, Path)>
{
/// Build a qualified path with a path builder.
pub fn as_(self) -> PathBuilder<Self> {
@@ -77,7 +70,7 @@
}
pub fn id<T>(self, id: T) -> F::Result
- where T: ToIdent,
+ where T: ToIdent
{
let path = Path {
global: false,
@@ -87,7 +80,7 @@
}
pub fn segment<T>(self, id: T) -> PathSegmentBuilder<QPathQSelfBuilder<F>>
- where T: ToIdent,
+ where T: ToIdent
{
let path = Path {
global: false,
@@ -98,7 +91,7 @@
}
impl<F> Invoke<Path> for QPathTyBuilder<F>
- where F: Invoke<(QSelf, Path)>,
+ where F: Invoke<(QSelf, Path)>
{
type Result = QPathQSelfBuilder<F>;
@@ -114,7 +107,7 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct QPathQSelfBuilder<F> {
builder: QPathBuilder<F>,
@@ -123,23 +116,23 @@
}
impl<F> QPathQSelfBuilder<F>
- where F: Invoke<(QSelf, Path)>,
+ where F: Invoke<(QSelf, Path)>
{
pub fn id<T>(self, id: T) -> F::Result
- where T: ToIdent,
+ where T: ToIdent
{
self.segment(id).build()
}
pub fn segment<T>(self, id: T) -> PathSegmentBuilder<QPathQSelfBuilder<F>>
- where T: ToIdent,
+ where T: ToIdent
{
PathSegmentBuilder::with_callback(id, self)
}
}
impl<F> Invoke<PathSegment> for QPathQSelfBuilder<F>
- where F: Invoke<(QSelf, Path)>,
+ where F: Invoke<(QSelf, Path)>
{
type Result = F::Result;
diff --git a/src/aster/ty.rs b/src/aster/ty.rs
index 04ff2a9..3d5de31 100644
--- a/src/aster/ty.rs
+++ b/src/aster/ty.rs
@@ -1,13 +1,4 @@
-use {
- Generics,
- Lifetime,
- MutTy,
- Mutability,
- Path,
- QSelf,
- Ty,
- TyParamBound,
-};
+use {Generics, Lifetime, MutTy, Mutability, Path, QSelf, Ty, TyParamBound};
use aster::ident::ToIdent;
use aster::invoke::{Invoke, Identity};
use aster::lifetime::IntoLifetime;
@@ -15,9 +6,9 @@
use aster::qpath::QPathBuilder;
use aster::ty_param::TyParamBoundBuilder;
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
-pub struct TyBuilder<F=Identity> {
+pub struct TyBuilder<F = Identity> {
callback: F,
}
@@ -28,12 +19,10 @@
}
impl<F> TyBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
pub fn with_callback(callback: F) -> Self {
- TyBuilder {
- callback: callback,
- }
+ TyBuilder { callback: callback }
}
pub fn build(self, ty: Ty) -> F::Result {
@@ -41,7 +30,7 @@
}
pub fn id<I>(self, id: I) -> F::Result
- where I: ToIdent,
+ where I: ToIdent
{
self.path().id(id).build()
}
@@ -170,22 +159,23 @@
}
pub fn object_sum(self) -> TyBuilder<TyObjectSumBuilder<F>> {
- TyBuilder::with_callback(TyObjectSumBuilder {
- builder: self,
- })
+ TyBuilder::with_callback(TyObjectSumBuilder { builder: self })
}
pub fn impl_trait(self) -> TyImplTraitTyBuilder<F> {
- TyImplTraitTyBuilder { builder: self, bounds: Vec::new() }
+ TyImplTraitTyBuilder {
+ builder: self,
+ bounds: Vec::new(),
+ }
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TyPathBuilder<F>(TyBuilder<F>);
impl<F> Invoke<Path> for TyPathBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = F::Result;
@@ -194,12 +184,12 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TyQPathBuilder<F>(TyBuilder<F>);
impl<F> Invoke<(QSelf, Path)> for TyQPathBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = F::Result;
@@ -208,12 +198,12 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TySliceBuilder<F>(TyBuilder<F>);
impl<F> Invoke<Ty> for TySliceBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = F::Result;
@@ -222,7 +212,7 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TyRefBuilder<F> {
builder: TyBuilder<F>,
@@ -231,7 +221,7 @@
}
impl<F> TyRefBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
pub fn mut_(mut self) -> Self {
self.mutability = Mutability::Mutable;
@@ -239,11 +229,9 @@
}
pub fn lifetime<N>(mut self, name: N) -> Self
- where N: ToIdent,
+ where N: ToIdent
{
- self.lifetime = Some(Lifetime {
- ident: name.to_ident(),
- });
+ self.lifetime = Some(Lifetime { ident: name.to_ident() });
self
}
@@ -261,7 +249,7 @@
}
impl<F> Invoke<Ty> for TyRefBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = F::Result;
@@ -270,12 +258,12 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TyOptionBuilder<F>(TyBuilder<F>);
impl<F> Invoke<Ty> for TyOptionBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = F::Result;
@@ -285,20 +273,20 @@
.id("std")
.id("option")
.segment("Option")
- .with_ty(ty)
- .build()
+ .with_ty(ty)
+ .build()
.build();
self.0.build_path(path)
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TyResultOkBuilder<F>(TyBuilder<F>);
impl<F> Invoke<Ty> for TyResultOkBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = TyBuilder<TyResultErrBuilder<F>>;
@@ -310,7 +298,7 @@
pub struct TyResultErrBuilder<F>(TyBuilder<F>, Ty);
impl<F> Invoke<Ty> for TyResultErrBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = F::Result;
@@ -320,21 +308,21 @@
.id("std")
.id("result")
.segment("Result")
- .with_ty(self.1)
- .with_ty(ty)
- .build()
+ .with_ty(self.1)
+ .with_ty(ty)
+ .build()
.build();
self.0.build_path(path)
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TyPhantomDataBuilder<F>(TyBuilder<F>);
impl<F> Invoke<Ty> for TyPhantomDataBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = F::Result;
@@ -344,20 +332,20 @@
.id("std")
.id("marker")
.segment("PhantomData")
- .with_ty(ty)
- .build()
+ .with_ty(ty)
+ .build()
.build();
self.0.build_path(path)
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TyBoxBuilder<F>(TyBuilder<F>);
impl<F> Invoke<Ty> for TyBoxBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = F::Result;
@@ -367,20 +355,20 @@
.id("std")
.id("boxed")
.segment("Box")
- .with_ty(ty)
- .build()
+ .with_ty(ty)
+ .build()
.build();
self.0.build_path(path)
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TyIteratorBuilder<F>(TyBuilder<F>);
impl<F> Invoke<Ty> for TyIteratorBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = F::Result;
@@ -390,22 +378,23 @@
.id("std")
.id("iter")
.segment("Iterator")
- .binding("Item").build(ty.clone())
- .build()
+ .binding("Item")
+ .build(ty.clone())
+ .build()
.build();
self.0.build_path(path)
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TyObjectSumBuilder<F> {
builder: TyBuilder<F>,
}
impl<F> Invoke<Ty> for TyObjectSumBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = TyObjectSumTyBuilder<F>;
@@ -425,10 +414,10 @@
}
impl<F> TyObjectSumTyBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
pub fn with_bounds<I>(mut self, iter: I) -> Self
- where I: Iterator<Item=TyParamBound>,
+ where I: Iterator<Item = TyParamBound>
{
self.bounds.extend(iter);
self
@@ -444,15 +433,14 @@
}
pub fn with_generics(self, generics: Generics) -> Self {
- self.with_lifetimes(
- generics.lifetimes.into_iter()
- .map(|def| def.lifetime)
- )
+ self.with_lifetimes(generics.lifetimes
+ .into_iter()
+ .map(|def| def.lifetime))
}
pub fn with_lifetimes<I, L>(mut self, lifetimes: I) -> Self
- where I: Iterator<Item=L>,
- L: IntoLifetime,
+ where I: Iterator<Item = L>,
+ L: IntoLifetime
{
for lifetime in lifetimes {
self = self.lifetime(lifetime);
@@ -462,7 +450,7 @@
}
pub fn lifetime<L>(self, lifetime: L) -> Self
- where L: IntoLifetime,
+ where L: IntoLifetime
{
self.bound().lifetime(lifetime)
}
@@ -474,7 +462,7 @@
}
impl<F> Invoke<TyParamBound> for TyObjectSumTyBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = Self;
@@ -483,7 +471,7 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TyImplTraitTyBuilder<F> {
builder: TyBuilder<F>,
@@ -491,10 +479,10 @@
}
impl<F> TyImplTraitTyBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
pub fn with_bounds<I>(mut self, iter: I) -> Self
- where I: Iterator<Item=TyParamBound>,
+ where I: Iterator<Item = TyParamBound>
{
self.bounds.extend(iter);
self
@@ -510,15 +498,14 @@
}
pub fn with_generics(self, generics: Generics) -> Self {
- self.with_lifetimes(
- generics.lifetimes.into_iter()
- .map(|def| def.lifetime)
- )
+ self.with_lifetimes(generics.lifetimes
+ .into_iter()
+ .map(|def| def.lifetime))
}
pub fn with_lifetimes<I, L>(mut self, lifetimes: I) -> Self
- where I: Iterator<Item=L>,
- L: IntoLifetime,
+ where I: Iterator<Item = L>,
+ L: IntoLifetime
{
for lifetime in lifetimes {
self = self.lifetime(lifetime);
@@ -528,7 +515,7 @@
}
pub fn lifetime<L>(self, lifetime: L) -> Self
- where L: IntoLifetime,
+ where L: IntoLifetime
{
self.bound().lifetime(lifetime)
}
@@ -540,7 +527,7 @@
}
impl<F> Invoke<TyParamBound> for TyImplTraitTyBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = Self;
@@ -549,7 +536,7 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TyTupleBuilder<F> {
builder: TyBuilder<F>,
@@ -557,10 +544,10 @@
}
impl<F> TyTupleBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
pub fn with_tys<I>(mut self, iter: I) -> Self
- where I: IntoIterator<Item=Ty>,
+ where I: IntoIterator<Item = Ty>
{
self.tys.extend(iter);
self
@@ -581,7 +568,7 @@
}
impl<F> Invoke<Ty> for TyTupleBuilder<F>
- where F: Invoke<Ty>,
+ where F: Invoke<Ty>
{
type Result = Self;
diff --git a/src/aster/ty_param.rs b/src/aster/ty_param.rs
index 592afd2..d81ccac 100644
--- a/src/aster/ty_param.rs
+++ b/src/aster/ty_param.rs
@@ -1,21 +1,12 @@
-use {
- Ident,
- LifetimeDef,
- Path,
- PolyTraitRef,
- TraitBoundModifier,
- Ty,
- TyParam,
- TyParamBound,
-};
+use {Ident, LifetimeDef, Path, PolyTraitRef, TraitBoundModifier, Ty, TyParam, TyParamBound};
use aster::invoke::{Invoke, Identity};
use aster::lifetime::{IntoLifetime, IntoLifetimeDef, LifetimeDefBuilder};
use aster::path::{IntoPath, PathBuilder};
use aster::ty::TyBuilder;
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
-pub struct TyParamBuilder<F=Identity> {
+pub struct TyParamBuilder<F = Identity> {
callback: F,
id: Ident,
bounds: Vec<TyParamBound>,
@@ -24,7 +15,7 @@
impl TyParamBuilder {
pub fn new<I>(id: I) -> Self
- where I: Into<Ident>,
+ where I: Into<Ident>
{
TyParamBuilder::with_callback(id, Identity)
}
@@ -35,7 +26,7 @@
}
impl<F> TyParamBuilder<F>
- where F: Invoke<TyParam>,
+ where F: Invoke<TyParam>
{
pub fn with_callback<I>(id: I, callback: F) -> Self
where I: Into<Ident>
@@ -80,13 +71,13 @@
}
pub fn trait_bound<P>(self, path: P) -> PolyTraitRefBuilder<Self>
- where P: IntoPath,
+ where P: IntoPath
{
PolyTraitRefBuilder::with_callback(path, self)
}
pub fn lifetime_bound<L>(mut self, lifetime: L) -> Self
- where L: IntoLifetime,
+ where L: IntoLifetime
{
let lifetime = lifetime.into_lifetime();
@@ -104,7 +95,7 @@
}
impl<F> Invoke<Ty> for TyParamBuilder<F>
- where F: Invoke<TyParam>,
+ where F: Invoke<TyParam>
{
type Result = Self;
@@ -114,7 +105,7 @@
}
impl<F> Invoke<TyParamBound> for TyParamBuilder<F>
- where F: Invoke<TyParam>,
+ where F: Invoke<TyParam>
{
type Result = Self;
@@ -124,7 +115,7 @@
}
impl<F> Invoke<PolyTraitRef> for TyParamBuilder<F>
- where F: Invoke<TyParam>,
+ where F: Invoke<TyParam>
{
type Result = Self;
@@ -133,9 +124,9 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
-pub struct TyParamBoundBuilder<F=Identity> {
+pub struct TyParamBoundBuilder<F = Identity> {
callback: F,
}
@@ -146,23 +137,19 @@
}
impl<F> TyParamBoundBuilder<F>
- where F: Invoke<TyParamBound>,
+ where F: Invoke<TyParamBound>
{
pub fn with_callback(callback: F) -> Self {
- TyParamBoundBuilder {
- callback: callback,
- }
+ TyParamBoundBuilder { callback: callback }
}
- pub fn build_trait(self,
- poly_trait: PolyTraitRef,
- modifier: TraitBoundModifier) -> F::Result {
+ pub fn build_trait(self, poly_trait: PolyTraitRef, modifier: TraitBoundModifier) -> F::Result {
let bound = TyParamBound::Trait(poly_trait, modifier);
self.callback.invoke(bound)
}
pub fn trait_<P>(self, path: P) -> PolyTraitRefBuilder<TraitTyParamBoundBuilder<F>>
- where P: IntoPath,
+ where P: IntoPath
{
let builder = TraitTyParamBoundBuilder {
builder: self,
@@ -173,7 +160,7 @@
}
pub fn maybe_trait<P>(self, path: P) -> PolyTraitRefBuilder<TraitTyParamBoundBuilder<F>>
- where P: IntoPath,
+ where P: IntoPath
{
let builder = TraitTyParamBoundBuilder {
builder: self,
@@ -189,21 +176,22 @@
.id("std")
.id("iter")
.segment("Iterator")
- .binding("Item").build(ty)
- .build()
- .build();
+ .binding("Item")
+ .build(ty)
+ .build()
+ .build();
self.trait_(path)
}
pub fn lifetime<L>(self, lifetime: L) -> F::Result
- where L: IntoLifetime,
+ where L: IntoLifetime
{
let lifetime = lifetime.into_lifetime();
self.callback.invoke(TyParamBound::Region(lifetime))
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct TraitTyParamBoundBuilder<F> {
builder: TyParamBoundBuilder<F>,
@@ -211,7 +199,7 @@
}
impl<F> Invoke<PolyTraitRef> for TraitTyParamBoundBuilder<F>
- where F: Invoke<TyParamBound>,
+ where F: Invoke<TyParamBound>
{
type Result = F::Result;
@@ -220,7 +208,7 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct PolyTraitRefBuilder<F> {
callback: F,
@@ -229,10 +217,10 @@
}
impl<F> PolyTraitRefBuilder<F>
- where F: Invoke<PolyTraitRef>,
+ where F: Invoke<PolyTraitRef>
{
pub fn with_callback<P>(path: P, callback: F) -> Self
- where P: IntoPath,
+ where P: IntoPath
{
PolyTraitRefBuilder {
callback: callback,
@@ -242,14 +230,14 @@
}
pub fn with_lifetime<L>(mut self, lifetime: L) -> Self
- where L: IntoLifetimeDef,
+ where L: IntoLifetimeDef
{
self.lifetimes.push(lifetime.into_lifetime_def());
self
}
pub fn lifetime<N>(self, name: N) -> LifetimeDefBuilder<Self>
- where N: Into<Ident>,
+ where N: Into<Ident>
{
LifetimeDefBuilder::with_callback(name, self)
}
@@ -263,7 +251,7 @@
}
impl<F> Invoke<LifetimeDef> for PolyTraitRefBuilder<F>
- where F: Invoke<PolyTraitRef>,
+ where F: Invoke<PolyTraitRef>
{
type Result = Self;
diff --git a/src/aster/where_predicate.rs b/src/aster/where_predicate.rs
index 22464cd..611d058 100644
--- a/src/aster/where_predicate.rs
+++ b/src/aster/where_predicate.rs
@@ -1,22 +1,14 @@
-use {
- Ident,
- Lifetime,
- LifetimeDef,
- Ty,
- TyParamBound,
- WhereBoundPredicate,
- WherePredicate,
- WhereRegionPredicate,
-};
+use {Ident, Lifetime, LifetimeDef, Ty, TyParamBound, WhereBoundPredicate, WherePredicate,
+ WhereRegionPredicate};
use aster::invoke::{Invoke, Identity};
use aster::lifetime::{IntoLifetime, IntoLifetimeDef, LifetimeDefBuilder};
use aster::path::IntoPath;
use aster::ty::TyBuilder;
use aster::ty_param::{TyParamBoundBuilder, PolyTraitRefBuilder, TraitTyParamBoundBuilder};
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
-pub struct WherePredicateBuilder<F=Identity> {
+pub struct WherePredicateBuilder<F = Identity> {
callback: F,
}
@@ -27,12 +19,10 @@
}
impl<F> WherePredicateBuilder<F>
- where F: Invoke<WherePredicate>,
+ where F: Invoke<WherePredicate>
{
pub fn with_callback(callback: F) -> Self {
- WherePredicateBuilder {
- callback: callback,
- }
+ WherePredicateBuilder { callback: callback }
}
pub fn bound(self) -> TyBuilder<Self> {
@@ -40,7 +30,7 @@
}
pub fn lifetime<L>(self, lifetime: L) -> WhereRegionPredicateBuilder<F>
- where L: IntoLifetime,
+ where L: IntoLifetime
{
WhereRegionPredicateBuilder {
callback: self.callback,
@@ -51,7 +41,7 @@
}
impl<F> Invoke<Ty> for WherePredicateBuilder<F>
- where F: Invoke<WherePredicate>,
+ where F: Invoke<WherePredicate>
{
type Result = WhereBoundPredicateTyBuilder<F>;
@@ -64,14 +54,14 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct WhereBoundPredicateBuilder<F> {
callback: F,
}
impl<F> Invoke<Ty> for WhereBoundPredicateBuilder<F>
- where F: Invoke<WherePredicate>,
+ where F: Invoke<WherePredicate>
{
type Result = WhereBoundPredicateTyBuilder<F>;
@@ -84,7 +74,7 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct WhereBoundPredicateTyBuilder<F> {
callback: F,
@@ -93,17 +83,17 @@
}
impl<F> WhereBoundPredicateTyBuilder<F>
- where F: Invoke<WherePredicate>,
+ where F: Invoke<WherePredicate>
{
pub fn with_for_lifetime<L>(mut self, lifetime: L) -> Self
- where L: IntoLifetimeDef,
+ where L: IntoLifetimeDef
{
self.bound_lifetimes.push(lifetime.into_lifetime_def());
self
}
pub fn for_lifetime<N>(self, name: N) -> LifetimeDefBuilder<Self>
- where N: Into<Ident>,
+ where N: Into<Ident>
{
LifetimeDefBuilder::with_callback(name, self)
}
@@ -127,26 +117,24 @@
TyParamBoundBuilder::with_callback(builder)
}
- pub fn trait_<P>(self, path: P)
- -> PolyTraitRefBuilder<
- TraitTyParamBoundBuilder<
- WhereBoundPredicateTyBoundsBuilder<F>
- >
- >
- where P: IntoPath,
+ pub fn trait_<P>
+ (self,
+ path: P)
+ -> PolyTraitRefBuilder<TraitTyParamBoundBuilder<WhereBoundPredicateTyBoundsBuilder<F>>>
+ where P: IntoPath
{
self.bound().trait_(path)
}
pub fn lifetime<L>(self, lifetime: L) -> WhereBoundPredicateTyBoundsBuilder<F>
- where L: IntoLifetime,
+ where L: IntoLifetime
{
self.bound().lifetime(lifetime)
}
}
impl<F> Invoke<LifetimeDef> for WhereBoundPredicateTyBuilder<F>
- where F: Invoke<WherePredicate>,
+ where F: Invoke<WherePredicate>
{
type Result = Self;
@@ -156,7 +144,7 @@
}
impl<F> Invoke<TyParamBound> for WhereBoundPredicateTyBuilder<F>
- where F: Invoke<WherePredicate>,
+ where F: Invoke<WherePredicate>
{
type Result = WhereBoundPredicateTyBoundsBuilder<F>;
@@ -165,7 +153,7 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct WhereBoundPredicateTyBoundsBuilder<F> {
callback: F,
@@ -175,17 +163,17 @@
}
impl<F> WhereBoundPredicateTyBoundsBuilder<F>
- where F: Invoke<WherePredicate>,
+ where F: Invoke<WherePredicate>
{
pub fn with_for_lifetime<L>(mut self, lifetime: L) -> Self
- where L: IntoLifetimeDef,
+ where L: IntoLifetimeDef
{
self.bound_lifetimes.push(lifetime.into_lifetime_def());
self
}
pub fn for_lifetime<N>(self, name: N) -> LifetimeDefBuilder<Self>
- where N: Into<Ident>,
+ where N: Into<Ident>
{
LifetimeDefBuilder::with_callback(name, self)
}
@@ -199,15 +187,14 @@
TyParamBoundBuilder::with_callback(self)
}
- pub fn trait_<P>(self, path: P)
- -> PolyTraitRefBuilder<TraitTyParamBoundBuilder<Self>>
- where P: IntoPath,
+ pub fn trait_<P>(self, path: P) -> PolyTraitRefBuilder<TraitTyParamBoundBuilder<Self>>
+ where P: IntoPath
{
self.bound().trait_(path)
}
pub fn lifetime<L>(self, lifetime: L) -> Self
- where L: IntoLifetime,
+ where L: IntoLifetime
{
self.bound().lifetime(lifetime)
}
@@ -224,7 +211,7 @@
}
impl<F> Invoke<LifetimeDef> for WhereBoundPredicateTyBoundsBuilder<F>
- where F: Invoke<WherePredicate>,
+ where F: Invoke<WherePredicate>
{
type Result = Self;
@@ -234,7 +221,7 @@
}
impl<F> Invoke<TyParamBound> for WhereBoundPredicateTyBoundsBuilder<F>
- where F: Invoke<WherePredicate>,
+ where F: Invoke<WherePredicate>
{
type Result = Self;
@@ -243,7 +230,7 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
pub struct WhereRegionPredicateBuilder<F> {
callback: F,
@@ -252,10 +239,10 @@
}
impl<F> WhereRegionPredicateBuilder<F>
- where F: Invoke<WherePredicate>,
+ where F: Invoke<WherePredicate>
{
pub fn bound<L>(mut self, lifetime: L) -> Self
- where L: IntoLifetime,
+ where L: IntoLifetime
{
self.bounds.push(lifetime.into_lifetime());
self
diff --git a/src/attr.rs b/src/attr.rs
index fa021d7..cb0eeec 100644
--- a/src/attr.rs
+++ b/src/attr.rs
@@ -61,7 +61,9 @@
fn inner(self) -> Self::Ret;
}
-impl<'a, T> FilterAttrs<'a> for T where T: IntoIterator<Item = &'a Attribute> {
+impl<'a, T> FilterAttrs<'a> for T
+ where T: IntoIterator<Item = &'a Attribute>
+{
type Ret = iter::Filter<T::IntoIter, fn(&&Attribute) -> bool>;
fn outer(self) -> Self::Ret {
@@ -206,14 +208,10 @@
impl ToTokens for Attribute {
fn to_tokens(&self, tokens: &mut Tokens) {
- if let Attribute {
- style,
- value: MetaItem::NameValue(
- ref name,
- Lit::Str(ref value, StrStyle::Cooked),
- ),
- is_sugared_doc: true,
- } = *self {
+ if let Attribute { style,
+ value: MetaItem::NameValue(ref name,
+ Lit::Str(ref value, StrStyle::Cooked)),
+ is_sugared_doc: true } = *self {
if name == "doc" {
match style {
AttrStyle::Inner if value.starts_with("//!") => {
diff --git a/src/escape.rs b/src/escape.rs
index fa19bbe..8eccb4e 100644
--- a/src/escape.rs
+++ b/src/escape.rs
@@ -11,19 +11,23 @@
}
'\\' => {
match chars.next() {
- Some((_, 'x')) => match backslash_x(&mut chars) {
- Some(ch) => s.push(ch),
- None => break,
- },
+ Some((_, 'x')) => {
+ match backslash_x(&mut chars) {
+ Some(ch) => s.push(ch),
+ None => break,
+ }
+ }
Some((_, 'n')) => s.push('\n'),
Some((_, 'r')) => s.push('\r'),
Some((_, 't')) => s.push('\t'),
Some((_, '\\')) => s.push('\\'),
Some((_, '0')) => s.push('\0'),
- Some((_, 'u')) => match backslash_u(&mut chars) {
- Some(ch) => s.push(ch),
- None => break,
- },
+ Some((_, 'u')) => {
+ match backslash_u(&mut chars) {
+ Some(ch) => s.push(ch),
+ None => break,
+ }
+ }
Some((_, '\'')) => s.push('\''),
Some((_, '"')) => s.push('"'),
Some((_, '\n')) => {
@@ -55,14 +59,14 @@
n = byte_offset;
break;
}
- '#' => {},
+ '#' => {}
_ => return IResult::Error,
}
}
for (byte_offset, ch) in chars {
if ch == '"' && input[byte_offset + 1..].starts_with(&input[..n]) {
let rest = &input[byte_offset + 1 + n..];
- let value = &input[n + 1 .. byte_offset];
+ let value = &input[n + 1..byte_offset];
return IResult::Done(rest, (value.to_owned(), n));
}
}
@@ -82,14 +86,18 @@
}
#[cfg_attr(feature = "clippy", allow(diverging_sub_expression))]
-fn backslash_x<I>(chars: &mut I) -> Option<char> where I: Iterator<Item = (usize, char)> {
+fn backslash_x<I>(chars: &mut I) -> Option<char>
+ where I: Iterator<Item = (usize, char)>
+{
let a = next_char!(chars @ '0'...'7');
let b = next_char!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F');
char_from_hex_bytes(&[a as u8, b as u8])
}
#[cfg_attr(feature = "clippy", allow(diverging_sub_expression, many_single_char_names))]
-fn backslash_u<I>(chars: &mut I) -> Option<char> where I: Iterator<Item = (usize, char)> {
+fn backslash_u<I>(chars: &mut I) -> Option<char>
+ where I: Iterator<Item = (usize, char)>
+{
next_char!(chars @ '{');
let a = next_char!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F');
let b = next_char!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F' | '}');
diff --git a/src/expr.rs b/src/expr.rs
index 9b9ab2c..c181801 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -417,12 +417,12 @@
tap!(ty: and_ascription => {
e = Expr::Type(Box::new(e), Box::new(ty));
})
- // TODO: Assign
- // TODO: AssignOp
- // TODO: Field
- // TODO: TupField
- // TODO: Index
- // TODO: Range
+ // TODO: Assign
+ // TODO: AssignOp
+ // TODO: Field
+ // TODO: TupField
+ // TODO: Index
+ // TODO: Range
|
tap!(_try: punct!("?") => {
e = Expr::Try(Box::new(e));
@@ -882,16 +882,16 @@
pat_ident // must be before pat_path
|
pat_path
- // TODO: Struct
- // TODO: TupleStruct
+ // TODO: Struct
+ // TODO: TupleStruct
|
pat_tuple
- // TODO: Box
+ // TODO: Box
|
pat_ref
|
pat_lit
- // TODO: Vec
+ // TODO: Vec
|
pat_mac
));
@@ -1117,7 +1117,9 @@
}
input.pat.to_tokens(tokens);
match input.ty {
- Ty::Infer => { /* nothing */ }
+ Ty::Infer => {
+ // nothing
+ }
_ => {
tokens.append(":");
input.ty.to_tokens(tokens);
@@ -1188,10 +1190,10 @@
qself.ty.to_tokens(tokens);
if qself.position > 0 {
tokens.append("as");
- for (i, segment) in path.segments.iter()
- .take(qself.position)
- .enumerate()
- {
+ for (i, segment) in path.segments
+ .iter()
+ .take(qself.position)
+ .enumerate() {
if i > 0 || path.global {
tokens.append("::");
}
@@ -1339,7 +1341,9 @@
tokens.append("=>");
self.body.to_tokens(tokens);
match *self.body {
- Expr::Block(_, _) => { /* no comma */ }
+ Expr::Block(_, _) => {
+ // no comma
+ }
_ => tokens.append(","),
}
}
@@ -1365,10 +1369,10 @@
qself.ty.to_tokens(tokens);
if qself.position > 0 {
tokens.append("as");
- for (i, segment) in path.segments.iter()
- .take(qself.position)
- .enumerate()
- {
+ for (i, segment) in path.segments
+ .iter()
+ .take(qself.position)
+ .enumerate() {
if i > 0 || path.global {
tokens.append("::");
}
@@ -1442,7 +1446,9 @@
fn to_tokens(&self, tokens: &mut Tokens) {
match *self {
CaptureBy::Value => tokens.append("move"),
- CaptureBy::Ref => { /* nothing */ }
+ CaptureBy::Ref => {
+ // nothing
+ }
}
}
}
@@ -1460,7 +1466,9 @@
impl ToTokens for BlockCheckMode {
fn to_tokens(&self, tokens: &mut Tokens) {
match *self {
- BlockCheckMode::Default => { /* nothing */ }
+ BlockCheckMode::Default => {
+ // nothing
+ }
BlockCheckMode::Unsafe => tokens.append("unsafe"),
}
}
@@ -1484,7 +1492,9 @@
mac.to_tokens(tokens);
match style {
MacStmtStyle::Semicolon => tokens.append(";"),
- MacStmtStyle::Braces | MacStmtStyle::NoBraces => { /* no semicolon */ }
+ MacStmtStyle::Braces | MacStmtStyle::NoBraces => {
+ // no semicolon
+ }
}
}
}
diff --git a/src/generics.rs b/src/generics.rs
index 8955271..d92d2b4 100644
--- a/src/generics.rs
+++ b/src/generics.rs
@@ -16,9 +16,7 @@
impl Lifetime {
pub fn new<T: Into<Ident>>(t: T) -> Self {
- Lifetime {
- ident: Ident::new(t),
- }
+ Lifetime { ident: Ident::new(t) }
}
}
diff --git a/src/ident.rs b/src/ident.rs
index adb4428..d01b922 100644
--- a/src/ident.rs
+++ b/src/ident.rs
@@ -39,7 +39,9 @@
}
}
-impl<T: ?Sized> PartialEq<T> for Ident where T: AsRef<str> {
+impl<T: ?Sized> PartialEq<T> for Ident
+ where T: AsRef<str>
+{
fn eq(&self, other: &T) -> bool {
self.0 == other.as_ref()
}
diff --git a/src/item.rs b/src/item.rs
index 8c87b3a..10b6589 100644
--- a/src/item.rs
+++ b/src/item.rs
@@ -69,11 +69,11 @@
///
/// E.g. `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`
Impl(Unsafety,
- ImplPolarity,
- Generics,
- Option<Path>, // (optional) trait this impl implements
- Box<Ty>, // self
- Vec<ImplItem>),
+ ImplPolarity,
+ Generics,
+ Option<Path>, // (optional) trait this impl implements
+ Box<Ty>, // self
+ Vec<ImplItem>),
/// A macro invocation (which includes macro definition).
///
/// E.g. `macro_rules! foo { .. }` or `foo!(..)`
@@ -93,7 +93,7 @@
Glob(Path),
/// `foo::bar::{a, b, c}`
- List(Path, Vec<PathListItem>)
+ List(Path, Vec<PathListItem>),
}
#[derive(Debug, Clone, Eq, PartialEq)]
@@ -241,23 +241,23 @@
named!(pub item -> Item, alt!(
item_extern_crate
- // TODO: Use
+ // TODO: Use
|
item_static
|
item_const
|
item_fn
- // TODO: Mod
- // TODO: ForeignMod
+ // TODO: Mod
+ // TODO: ForeignMod
|
item_ty
|
item_struct_or_enum
- // TODO: Union
- // TODO: Trait
- // TODO: DefaultImpl
- // TODO: Impl
+ // TODO: Union
+ // TODO: Trait
+ // TODO: DefaultImpl
+ // TODO: Impl
|
item_mac
));
@@ -530,7 +530,9 @@
generics.where_clause.to_tokens(tokens);
variant_data.to_tokens(tokens);
match *variant_data {
- VariantData::Struct(_) => { /* no semicolon */ }
+ VariantData::Struct(_) => {
+ // no semicolon
+ }
VariantData::Tuple(_) |
VariantData::Unit => tokens.append(";"),
}
@@ -538,7 +540,12 @@
ItemKind::Union(ref _variant_data, ref _generics) => unimplemented!(),
ItemKind::Trait(_unsafety, ref _generics, ref _bound, ref _item) => unimplemented!(),
ItemKind::DefaultImpl(_unsafety, ref _path) => unimplemented!(),
- ItemKind::Impl(_unsafety, _polarity, ref _generics, ref _path, ref _ty, ref _item) => unimplemented!(),
+ ItemKind::Impl(_unsafety,
+ _polarity,
+ ref _generics,
+ ref _path,
+ ref _ty,
+ ref _item) => unimplemented!(),
ItemKind::Mac(ref mac) => {
mac.path.to_tokens(tokens);
tokens.append("!");
@@ -547,9 +554,9 @@
tt.to_tokens(tokens);
}
match mac.tts.last() {
- Some(&TokenTree::Delimited(
- Delimited { delim: DelimToken::Brace, .. }
- )) => { /* no semicolon */ }
+ Some(&TokenTree::Delimited(Delimited { delim: DelimToken::Brace, .. })) => {
+ // no semicolon
+ }
_ => tokens.append(";"),
}
}
@@ -569,7 +576,9 @@
fn to_tokens(&self, tokens: &mut Tokens) {
match *self {
Unsafety::Unsafe => tokens.append("unsafe"),
- Unsafety::Normal => { /* nothing */ },
+ Unsafety::Normal => {
+ // nothing
+ }
}
}
}
@@ -578,7 +587,9 @@
fn to_tokens(&self, tokens: &mut Tokens) {
match *self {
Constness::Const => tokens.append("const"),
- Constness::NotConst => { /* nothing */ },
+ Constness::NotConst => {
+ // nothing
+ }
}
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 7173b6f..d80f41b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -19,54 +19,20 @@
mod escape;
mod attr;
-pub use attr::{
- Attribute,
- AttrStyle,
- MetaItem,
-};
+pub use attr::{Attribute, AttrStyle, MetaItem};
mod data;
-pub use data::{
- Discriminant,
- Field,
- Variant,
- VariantData,
- Visibility,
-};
+pub use data::{Discriminant, Field, Variant, VariantData, Visibility};
#[cfg(feature = "full")]
mod expr;
#[cfg(feature = "full")]
-pub use expr::{
- Arm,
- BinOp,
- BindingMode,
- Block,
- BlockCheckMode,
- CaptureBy,
- Expr,
- FieldPat,
- Local,
- MacStmtStyle,
- Pat,
- RangeLimits,
- Stmt,
- UnOp,
-};
+pub use expr::{Arm, BinOp, BindingMode, Block, BlockCheckMode, CaptureBy, Expr, FieldPat, Local,
+ MacStmtStyle, Pat, RangeLimits, Stmt, UnOp};
mod generics;
-pub use generics::{
- Generics,
- Lifetime,
- LifetimeDef,
- TraitBoundModifier,
- TyParam,
- TyParamBound,
- WhereBoundPredicate,
- WhereClause,
- WherePredicate,
- WhereRegionPredicate,
-};
+pub use generics::{Generics, Lifetime, LifetimeDef, TraitBoundModifier, TyParam, TyParamBound,
+ WhereBoundPredicate, WhereClause, WherePredicate, WhereRegionPredicate};
#[cfg(feature = "full")]
mod krate;
@@ -74,81 +40,33 @@
pub use krate::Crate;
mod ident;
-pub use ident::{
- Ident,
-};
+pub use ident::Ident;
#[cfg(feature = "full")]
mod item;
#[cfg(feature = "full")]
-pub use item::{
- Abi,
- Constness,
- Defaultness,
- FnArg,
- FnDecl,
- ForeignItemKind,
- ForeignItem,
- ForeignMod,
- ImplItem,
- ImplItemKind,
- ImplPolarity,
- Item,
- ItemKind,
- MethodSig,
- PathListItem,
- TraitItem,
- TraitItemKind,
- Unsafety,
- ViewPath,
-};
+pub use item::{Abi, Constness, Defaultness, FnArg, FnDecl, ForeignItemKind, ForeignItem,
+ ForeignMod, ImplItem, ImplItemKind, ImplPolarity, Item, ItemKind, MethodSig,
+ PathListItem, TraitItem, TraitItemKind, Unsafety, ViewPath};
mod lit;
-pub use lit::{
- FloatTy,
- IntTy,
- Lit,
- StrStyle,
-};
+pub use lit::{FloatTy, IntTy, Lit, StrStyle};
#[cfg(feature = "full")]
mod mac;
#[cfg(feature = "full")]
-pub use mac::{
- BinOpToken,
- DelimToken,
- Delimited,
- Mac,
- Token,
- TokenTree,
-};
+pub use mac::{BinOpToken, DelimToken, Delimited, Mac, Token, TokenTree};
mod macro_input;
-pub use macro_input::{
- Body,
- MacroInput,
-};
+pub use macro_input::{Body, MacroInput};
#[cfg(feature = "parsing")]
mod space;
mod ty;
-pub use ty::{
- AngleBracketedParameterData,
- BareFnArg,
- BareFnTy,
- FunctionRetTy,
- MutTy,
- Mutability,
- ParenthesizedParameterData,
- Path,
- PathParameters,
- PathSegment,
- PolyTraitRef,
- QSelf,
- Ty,
- TypeBinding,
-};
+pub use ty::{AngleBracketedParameterData, BareFnArg, BareFnTy, FunctionRetTy, MutTy, Mutability,
+ ParenthesizedParameterData, Path, PathParameters, PathSegment, PolyTraitRef, QSelf,
+ Ty, TypeBinding};
#[cfg(feature = "aster")]
pub mod aster;
@@ -199,7 +117,10 @@
unwrap("where clause", generics::parsing::where_clause, input)
}
- fn unwrap<T>(name: &'static str, f: fn(&str) -> IResult<&str, T>, input: &str) -> Result<T, String> {
+ fn unwrap<T>(name: &'static str,
+ f: fn(&str) -> IResult<&str, T>,
+ input: &str)
+ -> Result<T, String> {
match f(input) {
IResult::Done(rest, t) => {
if rest.is_empty() {
diff --git a/src/lit.rs b/src/lit.rs
index 2e67d82..f0b1430 100644
--- a/src/lit.rs
+++ b/src/lit.rs
@@ -26,7 +26,7 @@
/// A raw string, like `r##"foo"##`
///
/// The uint is the number of `#` symbols used
- Raw(usize)
+ Raw(usize),
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
@@ -41,7 +41,7 @@
U16,
U32,
U64,
- Unsuffixed
+ Unsuffixed,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
@@ -62,11 +62,11 @@
string
|
byte_string
- // TODO: Byte
- // TODO: Char
+ // TODO: Byte
+ // TODO: Char
|
int => { |(value, ty)| Lit::Int(value, ty) }
- // TODO: Float
+ // TODO: Float
|
keyword!("true") => { |_| Lit::Bool(true) }
|
@@ -137,7 +137,7 @@
let mut bytes = input.bytes().peekable();
while let Some(&b) = bytes.peek() {
match b {
- b'0' ... b'9' => {
+ b'0'...b'9' => {
value = match value.checked_mul(10) {
Some(value) => value,
None => return IResult::Error,
diff --git a/src/mac.rs b/src/mac.rs
index 7b80303..7377fd5 100644
--- a/src/mac.rs
+++ b/src/mac.rs
@@ -42,7 +42,7 @@
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Token {
- /* Expression-operator symbols. */
+ // Expression-operator symbols.
Eq,
Lt,
Le,
@@ -57,7 +57,7 @@
BinOp(BinOpToken),
BinOpEq(BinOpToken),
- /* Structural symbols */
+ // Structural symbols
At,
Dot,
DotDot,
@@ -73,10 +73,10 @@
Dollar,
Question,
- /* Literals */
+ // Literals
Literal(Lit),
- /* Name components */
+ // Name components
Ident(Ident),
Underscore,
Lifetime(Ident),
diff --git a/src/macro_input.rs b/src/macro_input.rs
index 92a8e79..77f1c55 100644
--- a/src/macro_input.rs
+++ b/src/macro_input.rs
@@ -98,7 +98,9 @@
Body::Struct(ref variant_data) => {
variant_data.to_tokens(tokens);
match *variant_data {
- VariantData::Struct(_) => { /* no semicolon */ }
+ VariantData::Struct(_) => {
+ // no semicolon
+ }
VariantData::Tuple(_) |
VariantData::Unit => tokens.append(";"),
}
diff --git a/src/nom.rs b/src/nom.rs
index d400312..23f54c2 100644
--- a/src/nom.rs
+++ b/src/nom.rs
@@ -281,7 +281,7 @@
let mut res = ::std::vec::Vec::new();
let mut input = $i;
- // get the first element
+// get the first element
match $submac!(input, $($args2)*) {
$crate::nom::IResult::Error => $crate::nom::IResult::Done(input, ::std::vec::Vec::new()),
$crate::nom::IResult::Done(i,o) => {
@@ -291,13 +291,13 @@
res.push(o);
input = i;
- // get the separator first
+// get the separator first
while let $crate::nom::IResult::Done(i2, _) = $sep!(input, $($args)*) {
if i2.len() == input.len() {
break;
}
- // get the element next
+// get the element next
if let $crate::nom::IResult::Done(i3,o3) = $submac!(i2, $($args2)*) {
if i3.len() == i2.len() {
break;
diff --git a/src/space.rs b/src/space.rs
index 5536df4..59a2b0f 100644
--- a/src/space.rs
+++ b/src/space.rs
@@ -11,18 +11,15 @@
while let Some((i, ch)) = chars.next() {
let s = &input[start + i..];
if ch == '/' {
- if s.starts_with("//")
- && (!s.starts_with("///") || s.starts_with("////"))
- && !s.starts_with("//!") {
+ if s.starts_with("//") && (!s.starts_with("///") || s.starts_with("////")) &&
+ !s.starts_with("//!") {
if let Some(len) = s.find('\n') {
start += i + len + 1;
chars = input[start..].char_indices();
continue;
}
break;
- } else if s.starts_with("/*")
- && !s.starts_with("/**")
- && !s.starts_with("/*!") {
+ } else if s.starts_with("/*") && !s.starts_with("/**") && !s.starts_with("/*!") {
match block_comment(s) {
IResult::Done(_, com) => {
start += i + com.len();
@@ -71,11 +68,7 @@
pub fn word_break(input: &str) -> IResult<&str, ()> {
match input.chars().next() {
- Some(ch) if UnicodeXID::is_xid_continue(ch) => {
- IResult::Error
- }
- Some(_) | None => {
- IResult::Done(input, ())
- }
+ Some(ch) if UnicodeXID::is_xid_continue(ch) => IResult::Error,
+ Some(_) | None => IResult::Done(input, ()),
}
}
diff --git a/src/ty.rs b/src/ty.rs
index 1c4917b..872ab1f 100644
--- a/src/ty.rs
+++ b/src/ty.rs
@@ -59,7 +59,9 @@
pub segments: Vec<PathSegment>,
}
-impl<T> From<T> for Path where T: Into<PathSegment> {
+impl<T> From<T> for Path
+ where T: Into<PathSegment>
+{
fn from(segment: T) -> Self {
Path {
global: false,
@@ -77,7 +79,9 @@
pub parameters: PathParameters,
}
-impl<T> From<T> for PathSegment where T: Into<Ident> {
+impl<T> From<T> for PathSegment
+ where T: Into<Ident>
+{
fn from(ident: T) -> Self {
PathSegment {
ident: ident.into(),
@@ -157,7 +161,7 @@
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct QSelf {
pub ty: Box<Ty>,
- pub position: usize
+ pub position: usize,
}
#[derive(Debug, Clone, Eq, PartialEq)]
@@ -470,10 +474,10 @@
qself.ty.to_tokens(tokens);
if qself.position > 0 {
tokens.append("as");
- for (i, segment) in path.segments.iter()
- .take(qself.position)
- .enumerate()
- {
+ for (i, segment) in path.segments
+ .iter()
+ .take(qself.position)
+ .enumerate() {
if i > 0 || path.global {
tokens.append("::");
}
diff --git a/src/visit.rs b/src/visit.rs
index d3f66cc..c4e6c2d 100644
--- a/src/visit.rs
+++ b/src/visit.rs
@@ -100,7 +100,7 @@
}
pub fn walk_poly_trait_ref<V>(visitor: &mut V, trait_ref: &PolyTraitRef, _: &TraitBoundModifier)
- where V: Visitor,
+ where V: Visitor
{
walk_list!(visitor, visit_lifetime_def, &trait_ref.bound_lifetimes);
visitor.visit_path(&trait_ref.trait_ref);
@@ -114,15 +114,14 @@
walk_list!(visitor, visit_variant, variants, ¯o_input.generics);
}
Body::Struct(ref variant_data) => {
- visitor.visit_variant_data(variant_data, ¯o_input.ident,
- ¯o_input.generics);
+ visitor.visit_variant_data(variant_data, ¯o_input.ident, ¯o_input.generics);
}
}
walk_list!(visitor, visit_attribute, ¯o_input.attrs);
}
pub fn walk_variant<V>(visitor: &mut V, variant: &Variant, generics: &Generics)
- where V: Visitor,
+ where V: Visitor
{
visitor.visit_ident(&variant.ident);
visitor.visit_variant_data(&variant.data, &variant.ident, generics);
@@ -131,17 +130,14 @@
pub fn walk_ty<V: Visitor>(visitor: &mut V, ty: &Ty) {
match *ty {
- Ty::Vec(ref inner) | Ty::Paren(ref inner) => {
- visitor.visit_ty(inner)
- }
- Ty::Ptr(ref mutable_type) => {
- visitor.visit_ty(&mutable_type.ty)
- }
+ Ty::Vec(ref inner) |
+ Ty::Paren(ref inner) => visitor.visit_ty(inner),
+ Ty::Ptr(ref mutable_type) => visitor.visit_ty(&mutable_type.ty),
Ty::Rptr(ref opt_lifetime, ref mutable_type) => {
walk_list!(visitor, visit_lifetime, opt_lifetime);
visitor.visit_ty(&mutable_type.ty)
}
- Ty::Never => {},
+ Ty::Never => {}
Ty::Tup(ref tuple_element_types) => {
walk_list!(visitor, visit_ty, tuple_element_types);
}
@@ -184,7 +180,7 @@
}
pub fn walk_path_parameters<V>(visitor: &mut V, path_parameters: &PathParameters)
- where V: Visitor,
+ where V: Visitor
{
match *path_parameters {
PathParameters::AngleBracketed(ref data) => {
@@ -224,17 +220,17 @@
walk_list!(visitor, visit_lifetime_def, &generics.lifetimes);
for predicate in &generics.where_clause.predicates {
match *predicate {
- WherePredicate::BoundPredicate(WhereBoundPredicate{ref bounded_ty,
- ref bounds,
- ref bound_lifetimes,
- ..}) => {
+ WherePredicate::BoundPredicate(WhereBoundPredicate { ref bounded_ty,
+ ref bounds,
+ ref bound_lifetimes,
+ .. }) => {
visitor.visit_ty(bounded_ty);
walk_list!(visitor, visit_ty_param_bound, bounds);
walk_list!(visitor, visit_lifetime_def, bound_lifetimes);
}
- WherePredicate::RegionPredicate(WhereRegionPredicate{ref lifetime,
- ref bounds,
- ..}) => {
+ WherePredicate::RegionPredicate(WhereRegionPredicate { ref lifetime,
+ ref bounds,
+ .. }) => {
visitor.visit_lifetime(lifetime);
walk_list!(visitor, visit_lifetime, bounds);
}