1

I have the following set of imports at the top of my program:

extern crate serde_bencode;
extern crate serde;
extern crate serde_bytes;
extern crate url;
extern crate url_serde;

use serde_bytes::ByteBuf;
use serde_bencode::de;
use serde_bencode::error::Result;
use serde_bencode::Error::{Custom, InvalidLength};
use self::url::{Url};

This program currently does compile. However, I don't understand why I need to write self on the use self::url::{Url}; line. None of the other use statements need self - why does url?

For context, the snippet above is from a file called file_reader.rs, in a directory with the following structure:

roar/
    file_reader.rs
    main.rs
    lib.rs

Edit: I just noticed that if I add the line extern crate url; to lib.rs, then I don't need the self; however, I don't know why this step is necessary.

Adam Hammes
  • 820
  • 1
  • 8
  • 22

0 Answers0