aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Sacchini <joey@sacchini.net>2020-10-19 12:41:46 -0400
committerJoey Sacchini <joey@sacchini.net>2020-10-19 12:41:46 -0400
commita673089adf23594c6ccd13f4bfdcaf86601148c4 (patch)
treed305a692a7ebffc2697990744a714845d8cb6366
parentf7f69d2d98a087f98ec81c3687567e02f0abed7e (diff)
downloadmcproto-rs-a673089adf23594c6ccd13f4bfdcaf86601148c4.tar.gz
mcproto-rs-a673089adf23594c6ccd13f4bfdcaf86601148c4.tar.bz2
mcproto-rs-a673089adf23594c6ccd13f4bfdcaf86601148c4.zip
remove compat layer (don't need it), and fix some other small issues with tests/compiling
-rw-r--r--Cargo.lock7
-rw-r--r--Cargo.toml3
-rw-r--r--src/chat.rs3
-rw-r--r--src/nbt.rs15
-rw-r--r--src/protocol.rs2
-rw-r--r--src/types.rs2
6 files changed, 16 insertions, 16 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 720eea9..0b731db 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -74,7 +74,6 @@ version = "0.2.0"
dependencies = [
"base64",
"flate2",
- "no-std-compat",
"paste",
"rand",
"serde",
@@ -92,12 +91,6 @@ dependencies = [
]
[[package]]
-name = "no-std-compat"
-version = "0.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c"
-
-[[package]]
name = "paste"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 9de278b..85dc86a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,9 +17,6 @@ version = "1.0.116"
features = [ "derive", "alloc" ]
default-features = false
-[target.'cfg(not(feature = "std"))'.dependencies]
-no-std-compat = "0.4.1"
-
[dev-dependencies]
flate2 = "1.0.17"
diff --git a/src/chat.rs b/src/chat.rs
index d00e9f1..77087da 100644
--- a/src/chat.rs
+++ b/src/chat.rs
@@ -1052,7 +1052,7 @@ pub mod tests {
text: String::default(),
base: {
let mut b = BaseComponent::default();
- b.extra = vec!(
+ b.extra = alloc::vec!(
Chat::Text(TextComponent{
text: "this is red, and ".to_owned(),
base: {
@@ -1081,6 +1081,7 @@ pub mod tests {
let traditional = out.to_traditional().expect("is text");
assert_eq!(traditional.as_str(), "§cthis is red, and §rthis is §e§lyellow");
+ #[cfg(feature="std")]
println!("{}", serde_json::to_string_pretty(&out).expect("should serialize fine"));
}
} \ No newline at end of file
diff --git a/src/nbt.rs b/src/nbt.rs
index ae4aae5..c58c2d2 100644
--- a/src/nbt.rs
+++ b/src/nbt.rs
@@ -521,10 +521,8 @@ impl Tag {
#[cfg(test)]
mod tests {
use super::*;
- use flate2::read::GzDecoder;
- use std::fs::File;
- use std::io::Read;
+ #[cfg(feature = "std")]
#[test]
fn test_read_bignbt_example() {
let actual = read_bigtest();
@@ -570,6 +568,7 @@ mod tests {
assert_eq!(actual, expected);
}
+ #[cfg(feature = "std")]
#[test]
fn test_serialize_bigtest() {
let (unzipped, result) = read_bigtest_with_bytes();
@@ -625,16 +624,19 @@ mod tests {
assert_eq!(original, unserialized);
}
+ #[cfg(feature = "std")]
#[test]
fn test_display() {
println!("{}", read_bigtest());
}
+ #[cfg(feature = "std")]
#[test]
fn test_debug() {
println!("{:?}", read_bigtest());
}
+ #[cfg(feature = "std")]
fn read_bigtest_with_bytes() -> (Vec<u8>, NamedTag) {
let unzipped = read_compressed_file("src/testdata/bigtest.nbt").expect("read nbt data");
let Deserialized {
@@ -646,11 +648,13 @@ mod tests {
(unzipped, result)
}
+ #[cfg(feature = "std")]
fn read_bigtest() -> NamedTag {
let (_, result) = read_bigtest_with_bytes();
result
}
+ #[cfg(feature = "std")]
fn bigtest_generate_byte_array() -> Vec<u8> {
const COUNT: usize = 1000;
let mut out = Vec::with_capacity(COUNT);
@@ -660,7 +664,12 @@ mod tests {
out
}
+ #[cfg(feature = "std")]
fn read_compressed_file(at: &str) -> std::io::Result<Vec<u8>> {
+ use flate2::read::GzDecoder;
+ use std::fs::File;
+ use std::io::Read;
+
let file = File::open(at)?;
let mut gz = GzDecoder::new(file);
let mut out = Vec::new();
diff --git a/src/protocol.rs b/src/protocol.rs
index 2e0151d..7a2002d 100644
--- a/src/protocol.rs
+++ b/src/protocol.rs
@@ -350,7 +350,7 @@ macro_rules! define_protocol {
#[derive(PartialEq, Debug)]
pub struct $rawdt<'a, T> {
pub data: &'a [u8],
- _typ: no_std_compat::marker::PhantomData<T>
+ _typ: core::marker::PhantomData<T>
}
impl<'a, T> $rawdt<'a, T> where T: crate::Deserialize {
diff --git a/src/types.rs b/src/types.rs
index f22b280..1c4ac71 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -845,7 +845,7 @@ mod tests {
#[test]
fn test_nbt() {
test_type(NamedNbtTag {
- root: nbt::Tag::Compound(vec![
+ root: nbt::Tag::Compound(alloc::vec![
nbt::Tag::String("test 123".to_owned()).with_name("abc 123")
])
.with_name("root"),