Remove usage of unstable feature try_from

This commit is contained in:
Simon Sapin 2017-10-11 20:22:06 +02:00
parent 4ee8f56b9c
commit 796a8dc618
2 changed files with 7 additions and 8 deletions

View file

@ -98,11 +98,11 @@ use servo_atoms::Atom;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use std::borrow::Cow; use std::borrow::Cow;
use std::cell::{Cell, Ref}; use std::cell::{Cell, Ref};
use std::convert::TryFrom;
use std::default::Default; use std::default::Default;
use std::fmt; use std::fmt;
use std::mem; use std::mem;
use std::rc::Rc; use std::rc::Rc;
use std::str::FromStr;
use style::CaseSensitivityExt; use style::CaseSensitivityExt;
use style::applicable_declarations::ApplicableDeclarationBlock; use style::applicable_declarations::ApplicableDeclarationBlock;
use style::attr::{AttrValue, LengthOrPercentageOrAuto}; use style::attr::{AttrValue, LengthOrPercentageOrAuto};
@ -213,10 +213,10 @@ pub enum AdjacentPosition {
BeforeEnd, BeforeEnd,
} }
impl<'a> TryFrom<&'a str> for AdjacentPosition { impl FromStr for AdjacentPosition {
type Error = Error; type Err = Error;
fn try_from(position: &'a str) -> Result<AdjacentPosition, Self::Error> { fn from_str(position: &str) -> Result<Self, Self::Err> {
match_ignore_ascii_case! { &*position, match_ignore_ascii_case! { &*position,
"beforebegin" => Ok(AdjacentPosition::BeforeBegin), "beforebegin" => Ok(AdjacentPosition::BeforeBegin),
"afterbegin" => Ok(AdjacentPosition::AfterBegin), "afterbegin" => Ok(AdjacentPosition::AfterBegin),
@ -2243,7 +2243,7 @@ impl ElementMethods for Element {
// https://dom.spec.whatwg.org/#dom-element-insertadjacentelement // https://dom.spec.whatwg.org/#dom-element-insertadjacentelement
fn InsertAdjacentElement(&self, where_: DOMString, element: &Element) fn InsertAdjacentElement(&self, where_: DOMString, element: &Element)
-> Fallible<Option<DomRoot<Element>>> { -> Fallible<Option<DomRoot<Element>>> {
let where_ = AdjacentPosition::try_from(&*where_)?; let where_ = where_.parse::<AdjacentPosition>()?;
let inserted_node = self.insert_adjacent(where_, element.upcast())?; let inserted_node = self.insert_adjacent(where_, element.upcast())?;
Ok(inserted_node.map(|node| DomRoot::downcast(node).unwrap())) Ok(inserted_node.map(|node| DomRoot::downcast(node).unwrap()))
} }
@ -2255,7 +2255,7 @@ impl ElementMethods for Element {
let text = Text::new(data, &document_from_node(self)); let text = Text::new(data, &document_from_node(self));
// Step 2. // Step 2.
let where_ = AdjacentPosition::try_from(&*where_)?; let where_ = where_.parse::<AdjacentPosition>()?;
self.insert_adjacent(where_, text.upcast()).map(|_| ()) self.insert_adjacent(where_, text.upcast()).map(|_| ())
} }
@ -2263,7 +2263,7 @@ impl ElementMethods for Element {
fn InsertAdjacentHTML(&self, position: DOMString, text: DOMString) fn InsertAdjacentHTML(&self, position: DOMString, text: DOMString)
-> ErrorResult { -> ErrorResult {
// Step 1. // Step 1.
let position = AdjacentPosition::try_from(&*position)?; let position = position.parse::<AdjacentPosition>()?;
let context = match position { let context = match position {
AdjacentPosition::BeforeBegin | AdjacentPosition::AfterEnd => { AdjacentPosition::BeforeBegin | AdjacentPosition::AfterEnd => {

View file

@ -13,7 +13,6 @@
#![feature(on_unimplemented)] #![feature(on_unimplemented)]
#![feature(plugin)] #![feature(plugin)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![feature(try_from)]
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![allow(non_snake_case)] #![allow(non_snake_case)]