What is diff in this two case using `use`?


#1

In this case Error:

extern crate postgres;
use postgres::{Connection, SslMode};


pub fn test_pg(){
	let conn =
    Connection::connect(
    "postgres://postgres:postgres@localhost/",
    &SslMode::None)
    .unwrap();
}

src\storage.rs:4:16: 4:24 error: unresolved import postgres::Connection. Did you mean self::postgres? [E0432]
src\storage.rs:4 use postgres::{Connection, SslMode};

But in this Ok

extern crate postgres;
//use postgres::{Connection, SslMode};
pub fn test_pg(){
	let conn =
    postgres::Connection::connect(
    "postgres://postgres:postgres@localhost/",
    &postgres::SslMode::None)
    .unwrap();
}

#2

use statements are relative to the crate root and the extern crate postgres; imports postgres into the current scope.

Generally, you should just put all extern crate foo; statements in lib.rs. The other way to fix this is to write use self::postgres::....