2

I'm using HTML5ever, and I'm trying to put attributes into a Vec<(String, String>) (although (&str, &str) would work too).

Unfortunately, html5ever's attribute values are in Tendril<UTF8>s, not Strings (or QualNames, &strs, etc.). How can I convert one of these Tendrils into a String?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
thatlittlegit
  • 69
  • 1
  • 8

2 Answers2

2

Use its Deref implementation:

extern crate tendril;

use tendril::{fmt::UTF8, Tendril};

fn example(t: &Tendril<UTF8>) -> &str {
    t
}

fn main() {}
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
2

Just like this

    //the value is Tendril<UTF8> type 
    String::from(value);