self in use statement in rust

  • March 18, 2021
  • Rust

I was going through some library code in a rust crate and this pattern had my head scratching:
std::io::{self,Cursor};

What this is equivalent to is:
use std::io;
use std::io::Cursor;
which means explicitly use std::io::Cursor and also use std::io itself. Thus, Cursor need not be prefixed but you’d still need to do io::BufReader and so on.




No Comments


You can leave the first : )



Leave a Reply

Your email address will not be published. Required fields are marked *