Skip to content

Commit

Permalink
Change to Rust 2021 edition
Browse files Browse the repository at this point in the history
MSRV of 1.63.0 covers that.
  • Loading branch information
heinrich5991 committed Feb 27, 2024
1 parent 40be227 commit 7209c54
Show file tree
Hide file tree
Showing 176 changed files with 387 additions and 859 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"common",
"datafile",
Expand Down
1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "common"
version = "0.0.1"
authors = ["heinrich5991 <heinrich5991@gmail.com>"]
license = "MIT/Apache-2.0"
edition = "2021"

[dependencies]
arrayvec = "0.5.2"
Expand Down
6 changes: 2 additions & 4 deletions common/benches/cast.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#[macro_use]
extern crate bencher;
extern crate common;

use bencher::benchmark_group;
use bencher::benchmark_main;
use bencher::black_box;
use bencher::Bencher;
use common::num::Cast;
Expand Down
2 changes: 1 addition & 1 deletion common/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub trait FileExt {
#[cfg(feature = "file_offset")]
impl FileExt for std::fs::File {
fn read_offset_retry(&self, buffer: &mut [u8], offset: u64) -> io::Result<usize> {
use num::Cast;
use crate::num::Cast;

// Make sure the additions in this function don't overflow
let _end_offset = offset
Expand Down
11 changes: 0 additions & 11 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
#[cfg(test)]
#[macro_use]
extern crate quickcheck;

extern crate arrayvec;
#[cfg(feature = "file_offset")]
extern crate file_offset;
#[cfg(feature = "serde")]
extern crate serde;
extern crate zerocopy;

pub use map_iter::MapIterator;
pub use slice::relative_size_of;
pub use slice::relative_size_of_mult;
Expand Down
1 change: 1 addition & 0 deletions common/src/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub fn truncated_arraystring<A: Array<Item = u8> + Copy>(mut s: &str) -> ArraySt
#[cfg(test)]
mod test {
use super::truncated_arraystring;
use quickcheck::quickcheck;
quickcheck! {
fn truncated_arraystring0(v: String) -> bool {
truncated_arraystring::<[u8; 0]>(&v);
Expand Down
5 changes: 2 additions & 3 deletions common/src/vec.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::relative_size_of_mult;
use crate::slice;
use std::mem;

use relative_size_of_mult;
use slice;

pub unsafe fn transmute<T, U>(vec: Vec<T>) -> Vec<U> {
slice::transmute::<T, U>(&vec); // Error checking done there.

Expand Down
3 changes: 2 additions & 1 deletion datafile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ name = "datafile"
version = "0.0.1"
authors = ["heinrich5991 <heinrich5991@gmail.com>"]
license = "MIT/Apache-2.0"
edition = "2021"

[dependencies]
common = { path = "../common/", features = ["file_offset"] }
hexdump = "0.1.1"
itertools = ">=0.3.0,<0.5.0"
log = "0.3.0"
logger = { path = "../logger/" }
zlib_minimal = { path = "../zlib_minimal/" }
zlib = { package = "zlib_minimal", path = "../zlib_minimal/" }
11 changes: 5 additions & 6 deletions datafile/src/bitmagic.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::format::OnlyI32;
use crate::raw::CallbackError;
use crate::raw::CallbackNew;
use crate::raw::CallbackReadData;
use crate::raw::CallbackReadError;
use std::mem;

use format::OnlyI32;
use raw::CallbackError;
use raw::CallbackNew;
use raw::CallbackReadData;
use raw::CallbackReadError;

pub use common::relative_size_of;
pub use common::relative_size_of_mult;
pub use common::slice::transmute as transmute_slice;
Expand Down
2 changes: 1 addition & 1 deletion datafile/src/buffer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::format::ItemView;
use common::MapIterator;
use format::ItemView;
use std::ops;

#[derive(Clone, Copy, Debug)]
Expand Down
13 changes: 6 additions & 7 deletions datafile/src/file.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use crate::format;
use crate::format::ItemView;
use crate::raw;
use crate::raw::CallbackError;
use crate::raw::CallbackNew;
use crate::raw::CallbackReadData;
use common::io::seek_overflow;
use common::io::FileExt;
use common::io::ReadExt;
Expand All @@ -11,13 +17,6 @@ use std::io::SeekFrom;
use std::ops;
use std::path::Path;

use format;
use format::ItemView;
use raw;
use raw::CallbackError;
use raw::CallbackNew;
use raw::CallbackReadData;

#[derive(Debug)]
pub enum Error {
Df(format::Error),
Expand Down
14 changes: 6 additions & 8 deletions datafile/src/format.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use std::mem;

use bitmagic::as_mut_i32_slice;
use bitmagic::to_little_endian;
use bitmagic::CallbackNewExt;
use crate::bitmagic::as_mut_i32_slice;
use crate::bitmagic::to_little_endian;
use crate::bitmagic::CallbackNewExt;
use crate::raw;
use crate::raw::CallbackNew;
use common::num::Cast;
use raw;
use raw::CallbackNew;
use std::mem;
use std::slice;
use zlib;

#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum Error {
Expand Down
5 changes: 0 additions & 5 deletions datafile/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#[macro_use]
extern crate log;

extern crate common;
extern crate hexdump;
extern crate itertools;
extern crate zlib_minimal as zlib;

pub use file::DataIter;
pub use file::Error;
pub use file::Reader;
Expand Down
19 changes: 8 additions & 11 deletions datafile/src/raw.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use crate::bitmagic::relative_size_of;
use crate::bitmagic::relative_size_of_mult;
use crate::bitmagic::transmute_slice;
use crate::bitmagic::CallbackNewExt;
use crate::bitmagic::CallbackReadDataExt;
use crate::format;
use crate::format::ItemView;
use crate::format::OnlyI32;
use common::num::Cast;
use common::MapIterator;
use hexdump::hexdump_iter;
use hexdump::sanitize_byte;
use itertools::Itertools;
use log;
use std::mem;
use std::ops;
use zlib;

use bitmagic::relative_size_of;
use bitmagic::relative_size_of_mult;
use bitmagic::transmute_slice;
use bitmagic::CallbackNewExt;
use bitmagic::CallbackReadDataExt;
use format;
use format::ItemView;
use format::OnlyI32;

#[derive(Clone, Copy, Eq, Hash, PartialEq, Debug)]
pub enum Version {
Expand Down
2 changes: 1 addition & 1 deletion demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "demo"
version = "0.0.1"
authors = ["heinrich5991 <heinrich5991@gmail.com>"]
license = "MIT/Apache-2.0"
edition = "2018"
edition = "2021"

[dependencies]
arrayvec = "0.5.2"
Expand Down
1 change: 0 additions & 1 deletion demo/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use common::digest::Sha256;
use common::num::Cast;
use std::convert::TryFrom;
use std::io;
use warn;
use warn::Warn;

pub const MAX_SNAPSHOT_SIZE: usize = 65536;
Expand Down
14 changes: 0 additions & 14 deletions demo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
extern crate arrayvec;
extern crate binrw;
extern crate buffer;
extern crate common;
extern crate gamenet_common;
extern crate gamenet_ddnet;
extern crate huffman;
#[macro_use]
extern crate matches;
extern crate packer;
extern crate snapshot;
extern crate thiserror;
extern crate warn;

pub mod ddnet;
mod format;
mod reader;
Expand Down
2 changes: 0 additions & 2 deletions demo/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use arrayvec::ArrayVec;
use binrw::BinRead;
use common::digest::Sha256;
use common::num::Cast;
use huffman;
use huffman::instances::TEEWORLDS as HUFFMAN;
use packer;
use std::io;
use thiserror::Error;
use warn::wrap;
Expand Down
1 change: 0 additions & 1 deletion demo/src/writer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use arrayvec::ArrayVec;
use binrw::BinWrite;
use buffer;
use common::digest::Sha256;
use common::num::Cast;
use huffman::instances::TEEWORLDS as HUFFMAN;
Expand Down
3 changes: 2 additions & 1 deletion downloader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ name = "downloader"
version = "0.0.1"
authors = ["heinrich5991 <heinrich5991@gmail.com>"]
license = "MIT/Apache-2.0"
edition = "2021"

[dependencies]
arrayvec = "0.5.2"
clap = "2.31.2"
common = { path = "../common/" }
event_loop = { path = "../event_loop/" }
gamenet_teeworlds_0_6 = { path = "../gamenet/teeworlds-0.6/" }
gamenet = { package = "gamenet_teeworlds_0_6", path = "../gamenet/teeworlds-0.6/" }
hexdump = "0.1.1"
itertools = ">=0.3.0,<0.5.0"
log = "0.3.1"
Expand Down
15 changes: 1 addition & 14 deletions downloader/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
extern crate arrayvec;
#[macro_use]
extern crate clap;
extern crate common;
extern crate event_loop;
extern crate gamenet_teeworlds_0_6 as gamenet;
extern crate hexdump;
extern crate itertools;
#[macro_use]
extern crate log;
extern crate logger;
extern crate packer;
extern crate rand;
extern crate snapshot;
extern crate tempfile;
extern crate warn;

use arrayvec::ArrayVec;
use clap::values_t;
use clap::App;
use clap::Arg;
use clap::Error;
Expand Down
1 change: 1 addition & 0 deletions event_loop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "event_loop"
version = "0.0.1"
authors = ["heinrich5991 <heinrich5991@gmail.com>"]
license = "MIT/Apache-2.0"
edition = "2021"

[dependencies]
arrayvec = "0.5.2"
Expand Down
8 changes: 0 additions & 8 deletions event_loop/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
extern crate arrayvec;
extern crate common;
extern crate hexdump;
extern crate itertools;
#[macro_use]
extern crate log;
extern crate logger;
extern crate net;
extern crate socket;
extern crate warn;

use arrayvec::ArrayVec;
use common::Takeable;
Expand Down
1 change: 1 addition & 0 deletions gamenet/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "gamenet_common"
version = "0.0.1"
authors = ["heinrich5991 <heinrich5991@gmail.com>"]
license = "MIT/Apache-2.0"
edition = "2021"

[dependencies]
arrayvec = "0.5.2"
Expand Down
2 changes: 0 additions & 2 deletions gamenet/common/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use packer;

#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Error {
ControlCharacters,
Expand Down
11 changes: 0 additions & 11 deletions gamenet/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
extern crate arrayvec;
extern crate buffer;
extern crate common;
extern crate packer;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate uuid;
extern crate warn;
extern crate zerocopy;

pub mod debug;
pub mod error;
pub mod msg;
Expand Down
6 changes: 4 additions & 2 deletions gamenet/common/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use crate::error::Error;
use crate::error::InvalidIntString;
use arrayvec::ArrayVec;
use buffer::CapacityError;
use common::slice;
use error::Error;
use error::InvalidIntString;
use packer::ExcessData;
use packer::Packer;
use packer::Unpacker;
use packer::Warning;
use serde_derive::Deserialize;
use serde_derive::Serialize;
use std::fmt;
use std::io::Write;
use std::mem;
Expand Down
2 changes: 2 additions & 0 deletions gamenet/common/src/snap_obj.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use serde_derive::Deserialize;
use serde_derive::Serialize;
use std::fmt;
use uuid::Uuid;

Expand Down
1 change: 1 addition & 0 deletions gamenet/ddnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "gamenet_ddnet"
version = "0.0.1"
authors = ["heinrich5991 <heinrich5991@gmail.com>"]
license = "MIT/Apache-2.0"
edition = "2021"

[dependencies]
arrayvec = "0.5.2"
Expand Down
8 changes: 0 additions & 8 deletions gamenet/ddnet/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
extern crate arrayvec;
extern crate buffer;
extern crate common;
extern crate gamenet_common;
extern crate packer;
extern crate uuid;
extern crate warn;

#[rustfmt::skip]
pub mod enums;
#[rustfmt::skip]
Expand Down
2 changes: 1 addition & 1 deletion gamenet/ddnet/src/msg/connless.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use buffer::CapacityError;
use common::pretty;
use error::Error;
use crate::error::Error;
use gamenet_common::msg::AddrPackedSliceExt;
use gamenet_common::msg::int_from_string;
use gamenet_common::msg::string_from_int;
Expand Down
4 changes: 2 additions & 2 deletions gamenet/ddnet/src/msg/game.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use buffer::CapacityError;
use common::pretty;
use enums;
use error::Error;
use crate::enums;
use crate::error::Error;
use gamenet_common::debug::DebugSlice;
use packer::Packer;
use packer::Unpacker;
Expand Down
Loading

0 comments on commit 7209c54

Please sign in to comment.