Added From<Ident> for TyParam
diff --git a/src/generics.rs b/src/generics.rs
index 0aeb29a..fbb89b1 100644
--- a/src/generics.rs
+++ b/src/generics.rs
@@ -93,6 +93,7 @@
}
}
+/// A generic type parameter, e.g. `T: Into<String>`.
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct TyParam {
pub attrs: Vec<Attribute>,
@@ -101,6 +102,17 @@
pub default: Option<Ty>,
}
+impl From<Ident> for TyParam {
+ fn from(ident: Ident) -> Self {
+ TyParam {
+ attrs: vec![],
+ ident: ident,
+ bounds: vec![],
+ default: None,
+ }
+ }
+}
+
/// The AST represents all type param bounds as types.
/// `typeck::collect::compute_bounds` matches these against
/// the "special" built-in traits (see `middle::lang_items`) and