1
votes

I tried to use the RSS crate in a project. I added rss = "1.5.0" to the dependencies in Cargo.toml and built my code:

extern crate regex;
extern crate rss;

use rss::Channel;

fn main() {
    let channel = Channel::from_url("https://feedpress.me/usererror.xml");
}

When I run cargo build, I have the following error:

$ cargo build
   Compiling rss_f v0.1.0 (file:///home/philippe/test/rss_f)
error[E0599]: no function or associated item named `from_url` found for type `rss::Channel` in the current scope
 --> src/main.rs:7:19
  |
7 |     let channel = Channel::from_url("https://feedpress.me/usererror.xml");
  |                   ^^^^^^^^^^^^^^^^^ function or associated item not found in `rss::Channel`

When I highlight the function in VScode, I have an error from RLS and at the same time Racer gives me the definition of the function. So the crate is installed but Cargo can't use it.

1

1 Answers

4
votes

If you re-read the documentation, emphasis mine:

From a URL

A channel can also be read from a URL.

Note: This requires enabling the from_url feature.

use rss::Channel;

let channel = Channel::from_url("http://example.com/feed.xml").unwrap();

Thus, you need to enable the feature in your Cargo.toml:

rss = { version = "1.5.0", features = ["from_url"] }