Selaa lähdekoodia

Remove all `external crate`!

Jing Yang 4 vuotta sitten
vanhempi
commit
5ae61e09a0

+ 1 - 0
kvraft/src/common.rs

@@ -1,6 +1,7 @@
 use std::sync::atomic::{AtomicU64, Ordering};
 
 use rand::{thread_rng, RngCore};
+use serde_derive::{Deserialize, Serialize};
 
 pub type ClerkId = u64;
 #[derive(

+ 0 - 9
kvraft/src/lib.rs

@@ -1,12 +1,3 @@
-extern crate labrpc;
-extern crate parking_lot;
-extern crate rand;
-extern crate ruaft;
-extern crate serde;
-#[macro_use]
-extern crate serde_derive;
-extern crate tokio;
-
 pub use client::Clerk;
 pub use server::KVServer;
 

+ 1 - 0
kvraft/src/server.rs

@@ -6,6 +6,7 @@ use std::sync::Arc;
 use std::time::Duration;
 
 use parking_lot::{Condvar, Mutex};
+use serde_derive::{Deserialize, Serialize};
 
 use ruaft::{ApplyCommandMessage, Persister, Raft, RpcClient, Term};
 use test_utils::thread_local_logger::LocalLogger;

+ 1 - 4
kvraft/tests/service_test.rs

@@ -1,7 +1,3 @@
-extern crate kvraft;
-#[macro_use]
-extern crate scopeguard;
-
 use std::sync::atomic::{AtomicUsize, Ordering};
 use std::sync::Arc;
 
@@ -11,6 +7,7 @@ use kvraft::testing_utils::config::{
 use kvraft::testing_utils::generic_test::{
     generic_test, spawn_clients, GenericTestParams,
 };
+use scopeguard::defer;
 use test_utils::init_test_log;
 use test_utils::thread_local_logger::LocalLogger;
 

+ 2 - 0
src/index_term.rs

@@ -1,3 +1,5 @@
+use serde_derive::{Deserialize, Serialize};
+
 use crate::{Index, LogEntry, Term};
 
 #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]

+ 1 - 10
src/lib.rs

@@ -1,13 +1,3 @@
-extern crate bincode;
-extern crate futures_channel;
-extern crate futures_util;
-extern crate labrpc;
-extern crate log;
-extern crate rand;
-#[macro_use]
-extern crate serde_derive;
-extern crate tokio;
-
 use std::convert::TryFrom;
 use std::sync::atomic::{AtomicBool, Ordering};
 use std::sync::Arc;
@@ -15,6 +5,7 @@ use std::time::Duration;
 
 use crossbeam_utils::sync::WaitGroup;
 use parking_lot::{Condvar, Mutex};
+use serde_derive::{Deserialize, Serialize};
 
 use crate::apply_command::ApplyCommandFnMut;
 pub use crate::apply_command::ApplyCommandMessage;

+ 2 - 0
src/log_array.rs

@@ -1,3 +1,5 @@
+use serde_derive::{Deserialize, Serialize};
+
 use crate::index_term::IndexTerm;
 use crate::{Index, LogEntry, Term};
 

+ 1 - 0
src/persister.rs

@@ -3,6 +3,7 @@ use std::convert::TryFrom;
 use bytes::Bytes;
 use serde::de::DeserializeOwned;
 use serde::Serialize;
+use serde_derive::{Deserialize, Serialize};
 
 use crate::log_array::LogArray;
 use crate::{Peer, RaftState, Term};

+ 0 - 4
test_utils/src/lib.rs

@@ -1,7 +1,3 @@
-extern crate env_logger;
-extern crate log;
-extern crate rand;
-
 mod logging;
 pub mod thread_local_logger;
 pub use logging::{init_log, LOG_DIR};

+ 1 - 8
tests/agreement_tests.rs

@@ -1,13 +1,6 @@
 #![allow(clippy::identity_op)]
-#[macro_use]
-extern crate anyhow;
-extern crate bytes;
-extern crate labrpc;
-extern crate ruaft;
-#[macro_use]
-extern crate scopeguard;
-
 use rand::{thread_rng, Rng};
+use scopeguard::defer;
 
 // This is to remove the annoying "unused code in config" warnings.
 pub mod config;

+ 1 - 0
tests/config/mod.rs

@@ -5,6 +5,7 @@ use std::sync::Arc;
 use std::time::Instant;
 
 pub use anyhow::Result;
+use anyhow::{anyhow, bail};
 use parking_lot::Mutex;
 use rand::{thread_rng, Rng};
 use tokio::time::Duration;

+ 1 - 7
tests/election_tests.rs

@@ -1,10 +1,4 @@
-#[macro_use]
-extern crate anyhow;
-extern crate bytes;
-extern crate labrpc;
-extern crate ruaft;
-#[macro_use]
-extern crate scopeguard;
+use scopeguard::defer;
 
 // This is to remove the annoying "unused code in config" warnings.
 pub mod config;

+ 1 - 7
tests/persist_tests.rs

@@ -1,17 +1,11 @@
 #![allow(clippy::identity_op)]
-#[macro_use]
-extern crate anyhow;
-extern crate bytes;
-extern crate labrpc;
-extern crate ruaft;
-#[macro_use]
-extern crate scopeguard;
 
 use std::sync::atomic::AtomicBool;
 use std::sync::atomic::Ordering;
 use std::sync::Arc;
 
 use rand::{thread_rng, Rng};
+use scopeguard::defer;
 
 // This is to remove the annoying "unused code in config" warnings.
 pub mod config;

+ 3 - 4
tests/snapshot_tests.rs

@@ -1,10 +1,9 @@
-extern crate kvraft;
-#[macro_use]
-extern crate scopeguard;
+use std::sync::Arc;
+
+use scopeguard::defer;
 
 use kvraft::testing_utils::config::{make_config, sleep_election_timeouts};
 use kvraft::testing_utils::generic_test::{generic_test, GenericTestParams};
-use std::sync::Arc;
 use test_utils::init_test_log;
 
 #[test]