Skip to content

Commit

Permalink
Remove unneeded extern crate statements
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Dec 19, 2019
1 parent 9b92c7d commit b98bb23
Show file tree
Hide file tree
Showing 26 changed files with 31 additions and 79 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ docopt = "1"
lazy_static = "1"
rand = "0.7"
rand_xorshift = "0.2"
serde = "1"
serde_derive = "1"
doc-comment = "0.3"

[dev-dependencies.serde]
version = "1.0.85"
features = ["derive"]
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ as:
rayon = "1.1"
```

and then add the following to your `lib.rs`:

```rust
extern crate rayon;
```

To use the Parallel Iterator APIs, a number of traits have to be in
scope. The easiest way to bring those things into scope is to use the
[Rayon prelude](https://docs.rs/rayon/*/rayon/prelude/index.html). In
Expand Down
4 changes: 0 additions & 4 deletions ci/compat-Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions examples/cpu_monitor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[macro_use]
extern crate serde_derive;

use docopt::Docopt;
use std::io;
use std::process;
Expand All @@ -25,7 +22,7 @@ Options:
-d N, --depth N Control how hard the dummy task works [default: 27]
";

#[derive(Deserialize)]
#[derive(serde::Deserialize)]
pub struct Args {
arg_scenario: String,
flag_depth: usize,
Expand Down
8 changes: 1 addition & 7 deletions rayon-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ use std::io;
use std::marker::PhantomData;
use std::str::FromStr;

#[cfg(any(debug_assertions))]
#[macro_use]
extern crate lazy_static;

#[macro_use]
mod log;
#[macro_use]
Expand Down Expand Up @@ -244,11 +240,9 @@ impl ThreadPoolBuilder {
/// A scoped pool may be useful in combination with scoped thread-local variables.
///
/// ```
/// #[macro_use]
/// extern crate scoped_tls;
/// # use rayon_core as rayon;
///
/// scoped_thread_local!(static POOL_DATA: Vec<i32>);
/// scoped_tls::scoped_thread_local!(static POOL_DATA: Vec<i32>);
///
/// fn main() -> Result<(), rayon::ThreadPoolBuildError> {
/// let pool_data = vec![1, 2, 3];
Expand Down
2 changes: 1 addition & 1 deletion rayon-core/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub(super) enum Event {
}

#[cfg(debug_assertions)]
lazy_static! {
lazy_static::lazy_static! {
pub(super) static ref LOG_ENV: bool =
env::var("RAYON_LOG").is_ok() || env::var("RAYON_RS_LOG").is_ok();
}
Expand Down
5 changes: 1 addition & 4 deletions rayon-core/tests/scoped_threadpool.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#[macro_use]
extern crate scoped_tls;

use crossbeam_utils::thread;
use rayon_core::ThreadPoolBuilder;

#[derive(PartialEq, Eq, Debug)]
struct Local(i32);

scoped_thread_local!(static LOCAL: Local);
scoped_tls::scoped_thread_local!(static LOCAL: Local);

#[test]
fn missing_scoped_tls() {
Expand Down
3 changes: 0 additions & 3 deletions rayon-core/tests/stack_overflow_crash.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(unix)]
extern crate libc;

use rayon_core::ThreadPoolBuilder;

use std::env;
Expand Down
6 changes: 4 additions & 2 deletions rayon-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ odds = "0.3"
rand = "0.7"
rand_xorshift = "0.2"
regex = "1"
serde = "1"
serde_derive = "1"
time = "0.1"

[dependencies.serde]
version = "1.0.85"
features = ["derive"]

[target.'cfg(unix)'.dependencies]
libc = "0.2"

Expand Down
2 changes: 0 additions & 2 deletions rayon-demo/src/fibonacci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
//! unless you have a whole lot of CPUs. The iterative version reveals the
//! joke.

extern crate test;

const N: u32 = 32;
const FN: u32 = 2_178_309;

Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/find/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ macro_rules! make_tests {
use rayon::prelude::*;
use test::Bencher;

lazy_static! {
lazy_static::lazy_static! {
static ref HAYSTACK: Vec<[u32; $n]> = {
let rng = crate::seeded_rng();
rng.sample_iter(&Standard)
Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/life/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use rayon::prelude::*;
#[cfg(test)]
mod bench;

#[derive(Deserialize)]
#[derive(serde::Deserialize)]
pub struct Args {
cmd_bench: bool,
cmd_play: bool,
Expand Down
8 changes: 0 additions & 8 deletions rayon-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,8 @@ mod str_split;
#[cfg(test)]
mod vec_collect;

#[macro_use]
extern crate serde_derive; // all
#[macro_use]
extern crate glium; // nbody
#[macro_use]
extern crate lazy_static; // find
#[cfg(test)]
extern crate test;
#[cfg(windows)]
extern crate winapi; // life

const USAGE: &str = "
Usage: rayon-demo bench
Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/matmul/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Options:
-h, --help Show this message.
";

#[derive(Deserialize)]
#[derive(serde::Deserialize)]
pub struct Args {
cmd_bench: bool,
flag_size: usize,
Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/mergesort/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Options:
-h, --help Show this message.
";

#[derive(Deserialize)]
#[derive(serde::Deserialize)]
pub struct Args {
cmd_bench: bool,
flag_size: usize,
Expand Down
4 changes: 2 additions & 2 deletions rayon-demo/src/nbody/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ Ported from the RiverTrail demo found at:
https://github.com/IntelLabs/RiverTrail/tree/master/examples/nbody-webgl
";

#[derive(Copy, Clone, PartialEq, Eq, Deserialize)]
#[derive(Copy, Clone, PartialEq, Eq, serde::Deserialize)]
pub enum ExecutionMode {
Par,
ParReduce,
Seq,
}

#[derive(Deserialize)]
#[derive(serde::Deserialize)]
pub struct Args {
cmd_bench: bool,
cmd_visualize: bool,
Expand Down
6 changes: 3 additions & 3 deletions rayon-demo/src/nbody/visualize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct Vertex {
position: [f32; 3],
}

implement_vertex!(Vertex, position);
glium::implement_vertex!(Vertex, position);

fn icosahedron() -> ([Vertex; 12], Vec<u8>) {
let phi = (1.0 + f32::sqrt(5.0)) / 2.0;
Expand Down Expand Up @@ -75,7 +75,7 @@ struct Instance {
world_position: [f32; 3],
}

implement_vertex!(Instance, color, world_position);
glium::implement_vertex!(Instance, color, world_position);

pub fn visualize_benchmarks(num_bodies: usize, mut mode: ExecutionMode) {
let mut events_loop = EventsLoop::new();
Expand Down Expand Up @@ -181,7 +181,7 @@ pub fn visualize_benchmarks(num_bodies: usize, mut mode: ExecutionMode) {
(&vertex_buffer, instance_buffer.per_instance().unwrap()),
&index_buffer,
&program,
&uniform! { matrix: view_proj },
&glium::uniform! { matrix: view_proj },
&params,
)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/noop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Options:
use crate::cpu_time;
use docopt::Docopt;

#[derive(Deserialize)]
#[derive(serde::Deserialize)]
pub struct Args {
flag_sleep: u64,
flag_iters: u64,
Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/quicksort/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Options:
-h, --help Show this message.
";

#[derive(Deserialize)]
#[derive(serde::Deserialize)]
pub struct Args {
cmd_bench: bool,
flag_size: usize,
Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/sieve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Options:
-h, --help Show this message.
";

#[derive(Deserialize)]
#[derive(serde::Deserialize)]
pub struct Args {
cmd_bench: bool,
}
Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/str_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rand::seq::SliceRandom;
use rayon::prelude::*;
use test::Bencher;

lazy_static! {
lazy_static::lazy_static! {
static ref HAYSTACK: String = {
let mut rng = crate::seeded_rng();
let mut bytes: Vec<u8> = "abcdefg ".bytes().cycle().take(1_000_000).collect();
Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/tsp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Options:
--from N Node index from which to start the search [default: 0].
";

#[derive(Deserialize)]
#[derive(serde::Deserialize)]
pub struct Args {
cmd_bench: bool,
arg_datafile: String,
Expand Down
4 changes: 2 additions & 2 deletions rayon-demo/src/tsp/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ use super::weight::Weight;
// NODE_COORD_SECTION
// 1 11003.611100 42102.500000

lazy_static! {
lazy_static::lazy_static! {
static ref HEADER: Regex = Regex::new(r"([A-Z_]+)\s*:(.*)").unwrap();
}

lazy_static! {
lazy_static::lazy_static! {
static ref COORD: Regex = Regex::new(r"([0-9]+) ([0-9.]+) ([0-9.]+)").unwrap();
}

Expand Down
9 changes: 0 additions & 9 deletions src/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,6 @@ pub trait ParallelIterator: Sized + Send {
/// # Examples
///
/// ```
/// extern crate rand;
/// extern crate rayon;
///
/// use rand::Rng;
/// use rayon::prelude::*;
///
Expand Down Expand Up @@ -514,9 +511,6 @@ pub trait ParallelIterator: Sized + Send {
/// # Examples
///
/// ```
/// extern crate rand;
/// extern crate rayon;
///
/// use rand::Rng;
/// use rayon::prelude::*;
///
Expand Down Expand Up @@ -636,9 +630,6 @@ pub trait ParallelIterator: Sized + Send {
/// # Examples
///
/// ```
/// extern crate rand;
/// extern crate rayon;
///
/// use rand::Rng;
/// use rayon::prelude::*;
///
Expand Down
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
//!
//! # Basic usage and the Rayon prelude
//!
//! First, you will need to add `rayon` to your `Cargo.toml` and put
//! `extern crate rayon` in your main file (`lib.rs`, `main.rs`).
//! First, you will need to add `rayon` to your `Cargo.toml`.
//!
//! Next, to use parallel iterators or the other high-level methods,
//! you need to import several traits. Those traits are bundled into
Expand Down Expand Up @@ -84,11 +83,7 @@
//! [faq]: https://github.com/rayon-rs/rayon/blob/master/FAQ.md

#[cfg(test)]
#[macro_use]
extern crate doc_comment;

#[cfg(test)]
doctest!("../README.md");
doc_comment::doctest!("../README.md");

#[macro_use]
mod delegate;
Expand Down
5 changes: 1 addition & 4 deletions tests/sort-panic-safe.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[macro_use]
extern crate lazy_static;

use rand::distributions::Uniform;
use rand::{thread_rng, Rng};
use rayon::prelude::*;
Expand All @@ -13,7 +10,7 @@ use std::thread;

static VERSIONS: AtomicUsize = AtomicUsize::new(0);

lazy_static! {
lazy_static::lazy_static! {
static ref DROP_COUNTS: Vec<AtomicUsize> = (0..20_000).map(|_| AtomicUsize::new(0)).collect();
}

Expand Down

0 comments on commit b98bb23

Please sign in to comment.