Skip to content

Commit 48d428d

Browse files
committed
Avoid using extern crate when not needed
Rust 2018 allows to skip importing external crates using `extern crate` expression in most of cases so update the code and examples to take advantage of it. `log` crate is imported the old way for now to avoid importing every level in every file using the `use` keyword.
1 parent 8caac44 commit 48d428d

File tree

12 files changed

+2
-51
lines changed

12 files changed

+2
-51
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ Add this to your `Cargo.toml`:
2828
[dependencies]
2929
fatfs = "0.4"
3030

31-
and this to your crate root:
32-
33-
extern crate fatfs;
34-
3531
You can start using the `fatfs` library now:
3632

3733
let img_file = File::open("fat.img")?;
@@ -43,7 +39,6 @@ You can start using the `fatfs` library now:
4339
Note: it is recommended to wrap the underlying file struct in a buffering/caching object like `BufStream` from
4440
`fscommon` crate. For example:
4541

46-
extern crate fscommon;
4742
let buf_stream = BufStream::new(img_file);
4843
let fs = fatfs::FileSystem::new(buf_stream, fatfs::FsOptions::new())?;
4944

examples/cat.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate fatfs;
2-
extern crate fscommon;
3-
41
use std::env;
52
use std::fs::File;
63
use std::io::{self, prelude::*};

examples/ls.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
extern crate chrono;
2-
extern crate fatfs;
3-
extern crate fscommon;
4-
51
use std::env;
62
use std::fs::File;
73
use std::io;

examples/mkfatfs.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate fatfs;
2-
extern crate fscommon;
3-
41
use std::env;
52
use std::fs;
63
use std::io;

examples/partition.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate fatfs;
2-
extern crate fscommon;
3-
41
use std::{fs, io};
52

63
use fatfs::{FileSystem, FsOptions};

examples/write.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate fatfs;
2-
extern crate fscommon;
3-
41
use std::fs::OpenOptions;
52
use std::io::{self, prelude::*};
63

src/boot_sector.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,7 @@ pub(crate) fn format_boot_sector<E: IoError>(
801801
#[cfg(test)]
802802
mod tests {
803803
use super::*;
804-
extern crate env_logger;
805-
use crate::core::u32;
804+
use core::u32;
806805

807806
fn init() {
808807
let _ = env_logger::builder().is_test(true).try_init();

src/dir_entry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use core::fmt;
66
#[cfg(not(feature = "unicode"))]
77
use core::iter;
88
use core::str;
9+
use bitflags::bitflags;
910

1011
#[cfg(feature = "lfn")]
1112
use crate::dir::LfnBuffer;

src/lib.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,9 @@
1010
//! fatfs = "0.4"
1111
//! ```
1212
//!
13-
//! And this in your crate root:
14-
//!
15-
//! ```rust
16-
//! extern crate fatfs;
17-
//! ```
18-
//!
1913
//! # Examples
2014
//!
2115
//! ```rust
22-
//! // Declare external crates
23-
//! // Note: `fscommon` crate is used to speedup IO operations
24-
//! extern crate fatfs;
25-
//! extern crate fscommon;
26-
//!
2716
//! use std::io::prelude::*;
2817
//!
2918
//! fn main() -> std::io::Result<()> {
@@ -60,14 +49,9 @@
6049
#![warn(clippy::pedantic)]
6150
#![allow(clippy::module_name_repetitions, clippy::cast_possible_truncation)]
6251

63-
#[macro_use]
64-
extern crate bitflags;
65-
6652
#[macro_use]
6753
extern crate log;
6854

69-
extern crate core;
70-
7155
#[cfg(all(not(feature = "std"), feature = "alloc"))]
7256
extern crate alloc;
7357

tests/format.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
extern crate env_logger;
2-
extern crate fatfs;
3-
extern crate fscommon;
4-
51
use std::io;
62
use std::io::prelude::*;
73

0 commit comments

Comments
 (0)