kuchiki-rs / kuchiki

(朽木) HTML/XML tree manipulation library for Rust
MIT License
470 stars 54 forks source link

no method named `from_http` found #20

Closed conopt closed 8 years ago

conopt commented 8 years ago

tried to compile examples/hyper.rs, got error: no method named from_http found for type html5ever::driver::Parser<kuchiki::parser::Sink> in the current scope.

SimonSapin commented 8 years ago

Hi. I could not reproduce this. Which version of kuchiki are you using? How are you compiling the example? With the latest master (which is 0.3.0 on crates.io), cargo run --example hyper should print a compiler warning and do nothing:

   Compiling kuchiki v0.3.0 (file:///…/kuchiki)
examples/hyper.rs:7:9: 7:28 warning: unused import, #[warn(unused_imports)] on by default
examples/hyper.rs:7     use kuchiki::traits::*;  // This file requires the `hyper` feature to be enabled
                            ^~~~~~~~~~~~~~~~~~~
     Running `target/debug/examples/hyper`

With cargo run --example hyper --features hyper it should compile correctly (though at the moment it’s buggy and panics at runtime, I’m not sure why).

SimonSapin commented 8 years ago

I’ve fixed the runtime error in 7398a604d8622c2a2612e69a732fdcc3ecc18967.

conopt commented 8 years ago

Hi. Here are the steps to reproduce:

  1. Create a new cargo project with dependencies kuchiki and hyper
  2. Copy the hyper example code to src/main.rs
  3. cargo run --features hyper

rust version: 1.6.0 kuchiki version: 0.3.0 system version: Mac OS X 10.11.

SimonSapin commented 8 years ago

Could you copy/paste your Cargo.toml file? What’s important is the hyper for kuchiki, not for your own crate. You can enable it with:

[dependencies]
kuchiki = {version = "0.3", features = ["hyper"]}
conopt commented 8 years ago

Oh! Sorry for that. I didn't enable hyper for kuchiki. Thanks for your help!

SimonSapin commented 8 years ago

I’ve expanded the docs a bit, although admittedly they’re still not easily discoverable: https://simonsapin.github.io/kuchiki/kuchiki/traits/trait.ParserExt.html