Remove need to enable feature(try_from).

This commit is contained in:
Bodil Stokke 2018-11-17 21:49:04 +00:00
parent 276ba31432
commit 5a72616f97
6 changed files with 4 additions and 35 deletions

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene, decl_macro, try_from)] #![feature(proc_macro_hygiene, decl_macro)]
extern crate rocket; extern crate rocket;
extern crate typed_html; extern crate typed_html;
@ -33,7 +33,7 @@ fn index() -> Html {
</head> </head>
<body> <body>
<h1 data-lol="omg">"Hello Kitty!"</h1> <h1 data-lol="omg">"Hello Kitty!"</h1>
<p class="official-position-of-sanrio-ltd"> <p class="official-position-of-sanrio-ltd emphasis">
"She is not a "<em><a href="https://en.wikipedia.org/wiki/Cat">"cat"</a></em>". She is a "<em>"human girl"</em>"." "She is not a "<em><a href="https://en.wikipedia.org/wiki/Cat">"cat"</a></em>". She is a "<em>"human girl"</em>"."
</p> </p>
<p class=["urgent", "question"]>"But how does she eat?"</p> <p class=["urgent", "question"]>"But how does she eat?"</p>

View File

@ -1,4 +1,3 @@
#![feature(try_from)]
#![feature(proc_macro_hygiene)] #![feature(proc_macro_hygiene)]
extern crate stdweb; extern crate stdweb;

View File

@ -174,7 +174,7 @@ impl Element {
value => { value => {
let value = process_value(value); let value = process_value(value);
body.extend(quote!( 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<Node, ParseError> { pub fn expand_html(input: &[Token]) -> Result<Node, ParseError> {
grammar::NodeParser::new().parse(Lexer::new(input)) grammar::NodeParser::new().parse(Lexer::new(input))
} }

View File

@ -1,4 +1,3 @@
#![feature(try_from)]
#![feature(proc_macro_hygiene)] #![feature(proc_macro_hygiene)]
#[macro_use] #[macro_use]

View File

@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::fmt::{Display, Error, Formatter}; use std::fmt::{Display, Error, Formatter};
use std::ops::Deref; use std::ops::Deref;
use std::str::FromStr; use std::str::FromStr;
@ -64,20 +63,6 @@ impl FromStr for Class {
} }
} }
impl TryFrom<String> for Class {
type Error = &'static str;
fn try_from(s: String) -> Result<Self, Self::Error> {
Self::try_new(s)
}
}
impl<'a> TryFrom<&'a str> for Class {
type Error = &'static str;
fn try_from(s: &'a str) -> Result<Self, Self::Error> {
Self::try_new(s)
}
}
impl From<Id> for Class { impl From<Id> for Class {
fn from(id: Id) -> Self { fn from(id: Id) -> Self {
Class(id.to_string()) Class(id.to_string())

View File

@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::fmt::{Display, Error, Formatter}; use std::fmt::{Display, Error, Formatter};
use std::ops::Deref; use std::ops::Deref;
use std::str::FromStr; use std::str::FromStr;
@ -59,20 +58,6 @@ impl FromStr for Id {
} }
} }
impl TryFrom<String> for Id {
type Error = &'static str;
fn try_from(s: String) -> Result<Self, Self::Error> {
Self::try_new(s)
}
}
impl<'a> TryFrom<&'a str> for Id {
type Error = &'static str;
fn try_from(s: &'a str) -> Result<Self, Self::Error> {
Self::try_new(s)
}
}
impl From<Class> for Id { impl From<Class> for Id {
fn from(c: Class) -> Self { fn from(c: Class) -> Self {
Id(c.to_string()) Id(c.to_string())