diff --git a/Cargo.toml b/Cargo.toml index ad0c633b..c174c043 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ name = "html5ever" version = "0.0.0" authors = [ "The html5ever Project Developers" ] +license = "MIT / Apache-2.0" [lib] name = "html5ever" diff --git a/src/tokenizer/buffer_queue.rs b/src/tokenizer/buffer_queue.rs index 791e99ae..b3ba7691 100644 --- a/src/tokenizer/buffer_queue.rs +++ b/src/tokenizer/buffer_queue.rs @@ -104,7 +104,7 @@ impl BufferQueue { let n = set.nonmember_prefix_len(&buf[*pos..]); if n > 0 { let new_pos = *pos + n; - let out = String::from_str(&buf[*pos..new_pos]); + let out = String::from(&buf[*pos..new_pos]); *pos = new_pos; (Some(NotFromSet(out)), new_pos >= buf.len()) } else { @@ -182,7 +182,7 @@ mod test { assert_eq!(bq.peek(), None); assert_eq!(bq.next(), None); - bq.push_back(String::from_str("abc"), 0); + bq.push_back(String::from("abc"), 0); assert_eq!(bq.peek(), Some('a')); assert_eq!(bq.next(), Some('a')); assert_eq!(bq.peek(), Some('b')); @@ -197,10 +197,10 @@ mod test { #[test] fn can_unconsume() { let mut bq = BufferQueue::new(); - bq.push_back(String::from_str("abc"), 0); + bq.push_back(String::from("abc"), 0); assert_eq!(bq.next(), Some('a')); - bq.push_front(String::from_str("xy")); + bq.push_front(String::from("xy")); assert_eq!(bq.next(), Some('x')); assert_eq!(bq.next(), Some('y')); assert_eq!(bq.next(), Some('b')); @@ -211,18 +211,18 @@ mod test { #[test] fn can_pop_except_set() { let mut bq = BufferQueue::new(); - bq.push_back(String::from_str("abc&def"), 0); + bq.push_back(String::from("abc&def"), 0); let mut pop = || bq.pop_except_from(small_char_set!('&')); - assert_eq!(pop(), Some(NotFromSet(String::from_str("abc")))); + assert_eq!(pop(), Some(NotFromSet(String::from("abc")))); assert_eq!(pop(), Some(FromSet('&'))); - assert_eq!(pop(), Some(NotFromSet(String::from_str("def")))); + assert_eq!(pop(), Some(NotFromSet(String::from("def")))); assert_eq!(pop(), None); } #[test] fn can_push_truncated() { let mut bq = BufferQueue::new(); - bq.push_back(String::from_str("abc"), 1); + bq.push_back(String::from("abc"), 1); assert_eq!(bq.next(), Some('b')); assert_eq!(bq.next(), Some('c')); assert_eq!(bq.next(), None); @@ -234,8 +234,8 @@ mod test { // integration tests for more thorough testing with many // different input buffer splits. let mut bq = BufferQueue::new(); - bq.push_back(String::from_str("a"), 0); - bq.push_back(String::from_str("bc"), 0); + bq.push_back(String::from("a"), 0); + bq.push_back(String::from("bc"), 0); assert_eq!(bq.eat("abcd"), None); assert_eq!(bq.eat("ax"), Some(false)); assert_eq!(bq.eat("ab"), Some(true)); diff --git a/src/tokenizer/char_ref/mod.rs b/src/tokenizer/char_ref/mod.rs index 5141de4f..a42c15e5 100644 --- a/src/tokenizer/char_ref/mod.rs +++ b/src/tokenizer/char_ref/mod.rs @@ -199,7 +199,7 @@ impl CharRefTokenizer { } fn unconsume_numeric(&mut self, tokenizer: &mut Tokenizer) -> Status { - let mut unconsume = String::from_str("#"); + let mut unconsume = String::from("#"); match self.hex_marker { Some(c) => unconsume.push(c), None => (), @@ -345,7 +345,7 @@ impl CharRefTokenizer { self.unconsume_name(tokenizer); self.finish_none() } else { - tokenizer.unconsume(String::from_str(&self.name_buf()[name_len..])); + tokenizer.unconsume(String::from(&self.name_buf()[name_len..])); self.result = Some(CharRef { chars: [from_u32(c1).unwrap(), from_u32(c2).unwrap()], num_chars: if c2 == 0 { 1 } else { 2 }, @@ -389,7 +389,7 @@ impl CharRefTokenizer { } Octothorpe => { - tokenizer.unconsume(String::from_str("#")); + tokenizer.unconsume(String::from("#")); tokenizer.emit_error(Borrowed("EOF after '#' in character reference")); self.finish_none(); } diff --git a/src/tokenizer/mod.rs b/src/tokenizer/mod.rs index 476db92e..b90c8053 100644 --- a/src/tokenizer/mod.rs +++ b/src/tokenizer/mod.rs @@ -1327,38 +1327,38 @@ mod test { fn push_to_None_gives_singleton() { let mut s: Option = None; option_push(&mut s, 'x'); - assert_eq!(s, Some(String::from_str("x"))); + assert_eq!(s, Some(String::from("x"))); } #[test] fn push_to_empty_appends() { let mut s: Option = Some(String::new()); option_push(&mut s, 'x'); - assert_eq!(s, Some(String::from_str("x"))); + assert_eq!(s, Some(String::from("x"))); } #[test] fn push_to_nonempty_appends() { - let mut s: Option = Some(String::from_str("y")); + let mut s: Option = Some(String::from("y")); option_push(&mut s, 'x'); - assert_eq!(s, Some(String::from_str("yx"))); + assert_eq!(s, Some(String::from("yx"))); } #[test] fn append_appends() { - let mut s = String::from_str("foo"); - append_strings(&mut s, String::from_str("bar")); - assert_eq!(s, String::from_str("foobar")); + let mut s = String::from("foo"); + append_strings(&mut s, String::from("bar")); + assert_eq!(s, String::from("foobar")); } #[test] fn append_to_empty_does_not_copy() { - let mut lhs: String = String::from_str(""); + let mut lhs: String = String::from(""); let rhs: Vec = vec![b'f', b'o', b'o']; let ptr_old = rhs[0] as *const u8; append_strings(&mut lhs, String::from_utf8(rhs).unwrap()); - assert_eq!(lhs, String::from_str("foo")); + assert_eq!(lhs, String::from("foo")); let ptr_new = lhs.into_bytes()[0] as *const u8; assert_eq!(ptr_old, ptr_new); diff --git a/src/tree_builder/mod.rs b/src/tree_builder/mod.rs index 3d9e88b5..1f806658 100644 --- a/src/tree_builder/mod.rs +++ b/src/tree_builder/mod.rs @@ -349,11 +349,11 @@ impl TreeBuilder token = CharacterTokens( if is_ws { Whitespace } else { NotWhitespace }, - String::from_str(&buf[..len])); + String::from(&buf[..len])); if len < buf.len() { more_tokens.push_back( - CharacterTokens(NotSplit, String::from_str(&buf[len..]))); + CharacterTokens(NotSplit, String::from(&buf[len..]))); } } }