Document From trait for LhsExpr

This commit is contained in:
Charles Gleason 2019-09-03 18:42:58 -04:00
parent b9de4ef89e
commit 194d357e03

View File

@ -66,6 +66,10 @@ pub(super) enum LhsExpr {
}
impl From<Option<ThinVec<Attribute>>> for LhsExpr {
/// Converts `Some(attrs)` into `LhsExpr::AttributesParsed(attrs)`
/// and `None` into `LhsExpr::NotYetParsed`.
///
/// This conversion does not allocate.
fn from(o: Option<ThinVec<Attribute>>) -> Self {
if let Some(attrs) = o {
LhsExpr::AttributesParsed(attrs)
@ -76,6 +80,9 @@ impl From<Option<ThinVec<Attribute>>> for LhsExpr {
}
impl From<P<Expr>> for LhsExpr {
/// Converts the `expr: P<Expr>` into `LhsExpr::AlreadyParsed(expr)`.
///
/// This conversion does not allocate.
fn from(expr: P<Expr>) -> Self {
LhsExpr::AlreadyParsed(expr)
}