From 5a72616f97b0a9310fec7568570ba2c0df6e6560 Mon Sep 17 00:00:00 2001 From: Bodil Stokke Date: Sat, 17 Nov 2018 21:49:04 +0000 Subject: [PATCH] Remove need to enable feature(try_from). --- examples/rocket/src/main.rs | 4 ++-- examples/wasm/src/main.rs | 1 - macros/src/html.rs | 3 ++- typed-html/src/bin/main.rs | 1 - typed-html/src/types/class.rs | 15 --------------- typed-html/src/types/id.rs | 15 --------------- 6 files changed, 4 insertions(+), 35 deletions(-) diff --git a/examples/rocket/src/main.rs b/examples/rocket/src/main.rs index 6855384..e19ef2c 100644 --- a/examples/rocket/src/main.rs +++ b/examples/rocket/src/main.rs @@ -1,4 +1,4 @@ -#![feature(proc_macro_hygiene, decl_macro, try_from)] +#![feature(proc_macro_hygiene, decl_macro)] extern crate rocket; extern crate typed_html; @@ -33,7 +33,7 @@ fn index() -> Html {

"Hello Kitty!"

-

+

"She is not a ""cat"". She is a ""human girl""."

"But how does she eat?"

diff --git a/examples/wasm/src/main.rs b/examples/wasm/src/main.rs index 8d93c37..6082f93 100644 --- a/examples/wasm/src/main.rs +++ b/examples/wasm/src/main.rs @@ -1,4 +1,3 @@ -#![feature(try_from)] #![feature(proc_macro_hygiene)] extern crate stdweb; diff --git a/macros/src/html.rs b/macros/src/html.rs index 0a4ec98..1210534 100644 --- a/macros/src/html.rs +++ b/macros/src/html.rs @@ -174,7 +174,7 @@ impl Element { value => { let value = process_value(value); body.extend(quote!( - element.attrs.$key = Some(std::convert::TryInto::try_into($value).unwrap()); + element.attrs.$key = Some(std::convert::Into::into($value)); )); } } @@ -212,6 +212,7 @@ impl Element { } } +// FIXME report a decent error when the macro contains multiple top level elements pub fn expand_html(input: &[Token]) -> Result { grammar::NodeParser::new().parse(Lexer::new(input)) } diff --git a/typed-html/src/bin/main.rs b/typed-html/src/bin/main.rs index 3142630..2ff20fb 100644 --- a/typed-html/src/bin/main.rs +++ b/typed-html/src/bin/main.rs @@ -1,4 +1,3 @@ -#![feature(try_from)] #![feature(proc_macro_hygiene)] #[macro_use] diff --git a/typed-html/src/types/class.rs b/typed-html/src/types/class.rs index 2528321..b8201fb 100644 --- a/typed-html/src/types/class.rs +++ b/typed-html/src/types/class.rs @@ -1,4 +1,3 @@ -use std::convert::TryFrom; use std::fmt::{Display, Error, Formatter}; use std::ops::Deref; use std::str::FromStr; @@ -64,20 +63,6 @@ impl FromStr for Class { } } -impl TryFrom for Class { - type Error = &'static str; - fn try_from(s: String) -> Result { - Self::try_new(s) - } -} - -impl<'a> TryFrom<&'a str> for Class { - type Error = &'static str; - fn try_from(s: &'a str) -> Result { - Self::try_new(s) - } -} - impl From for Class { fn from(id: Id) -> Self { Class(id.to_string()) diff --git a/typed-html/src/types/id.rs b/typed-html/src/types/id.rs index b8d18e7..74ab24e 100644 --- a/typed-html/src/types/id.rs +++ b/typed-html/src/types/id.rs @@ -1,4 +1,3 @@ -use std::convert::TryFrom; use std::fmt::{Display, Error, Formatter}; use std::ops::Deref; use std::str::FromStr; @@ -59,20 +58,6 @@ impl FromStr for Id { } } -impl TryFrom for Id { - type Error = &'static str; - fn try_from(s: String) -> Result { - Self::try_new(s) - } -} - -impl<'a> TryFrom<&'a str> for Id { - type Error = &'static str; - fn try_from(s: &'a str) -> Result { - Self::try_new(s) - } -} - impl From for Id { fn from(c: Class) -> Self { Id(c.to_string())