Skip to content

Commit 5d2cbcd

Browse files
committed
Eliminate lib module
1 parent 31198f5 commit 5d2cbcd

File tree

22 files changed

+85
-65
lines changed

22 files changed

+85
-65
lines changed

src/de.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
use crate::error::{Error, ErrorCode, Result};
44
#[cfg(feature = "float_roundtrip")]
55
use crate::lexical;
6-
use crate::lib::str::FromStr;
7-
use crate::lib::*;
86
use crate::number::Number;
97
use crate::read::{self, Fused, Reference};
8+
use alloc::string::String;
9+
use alloc::vec::Vec;
10+
#[cfg(feature = "float_roundtrip")]
11+
use core::iter;
12+
use core::iter::FusedIterator;
13+
use core::marker::PhantomData;
14+
use core::result;
15+
use core::str::FromStr;
1016
use serde::de::{self, Expected, Unexpected};
1117
use serde::{forward_to_deserialize_any, serde_if_integer128};
1218

src/error.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
//! When serializing or deserializing JSON goes wrong.
22
33
use crate::io;
4-
use crate::lib::str::FromStr;
5-
use crate::lib::*;
4+
use alloc::boxed::Box;
5+
use alloc::string::{String, ToString};
6+
use core::fmt::{self, Debug, Display};
7+
use core::result;
8+
use core::str::FromStr;
69
use serde::{de, ser};
10+
#[cfg(feature = "std")]
11+
use std::error;
712

813
/// This type represents all possible errors that can occur when serializing or
914
/// deserializing JSON data.

src/io/core.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//! Reimplements core logic and types from `std::io` in an `alloc`-friendly
22
//! fashion.
33
4-
use crate::lib::*;
4+
use alloc::vec::Vec;
5+
use core::fmt::{self, Display};
6+
use core::result;
57

68
pub enum ErrorKind {
79
Other,

src/lexical/bhcomp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use super::float::*;
1212
use super::math::*;
1313
use super::num::*;
1414
use super::rounding::*;
15-
use crate::lib::{cmp, mem};
15+
use core::{cmp, mem};
1616

1717
// MANTISSA
1818

src/lexical/bignum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Big integer type definition.
44
55
use super::math::*;
6-
use crate::lib::Vec;
6+
use alloc::vec::Vec;
77

88
/// Storage for a big integer type.
99
#[derive(Clone, PartialEq, Eq)]

src/lexical/math.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
use super::large_powers;
1010
use super::num::*;
1111
use super::small_powers::*;
12-
use crate::lib::{cmp, iter, mem, Vec};
12+
use alloc::vec::Vec;
13+
use core::{cmp, iter, mem};
1314

1415
// ALIASES
1516
// -------

src/lexical/num.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
//! Utilities for Rust numbers.
44
5-
use crate::lib::ops;
5+
use core::ops;
66

77
/// Precalculated values of radix**i for i in range [0, arr.len()-1].
88
/// Each value can be **exactly** represented as that type.

src/lexical/rounding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use super::float::ExtendedFloat;
66
use super::num::*;
77
use super::shift::*;
8-
use crate::lib::mem;
8+
use core::mem;
99

1010
// MASKS
1111

src/lexical/shift.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Bit-shift helpers.
44
55
use super::float::ExtendedFloat;
6-
use crate::lib::mem;
6+
use core::mem;
77

88
// Shift extended-precision float right `shift` bytes.
99
#[inline]

src/lib.rs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -360,38 +360,8 @@
360360
#![cfg_attr(not(feature = "std"), no_std)]
361361
#![cfg_attr(docsrs, feature(doc_cfg))]
362362

363-
////////////////////////////////////////////////////////////////////////////////
364-
365363
extern crate alloc;
366364

367-
/// A facade around all the types we need from the `std`, `core`, and `alloc`
368-
/// crates. This avoids elaborate import wrangling having to happen in every
369-
/// module.
370-
mod lib {
371-
pub use core::cell::{Cell, RefCell};
372-
pub use core::clone::{self, Clone};
373-
pub use core::convert::{self, From, Into};
374-
pub use core::default::{self, Default};
375-
pub use core::fmt::{self, Debug, Display};
376-
pub use core::hash::{self, Hash, Hasher};
377-
pub use core::iter::FusedIterator;
378-
pub use core::marker::{self, PhantomData};
379-
pub use core::ops::{Bound, RangeBounds};
380-
pub use core::result::{self, Result};
381-
pub use core::{borrow, char, cmp, iter, mem, num, ops, slice, str};
382-
383-
pub use alloc::borrow::{Cow, ToOwned};
384-
pub use alloc::boxed::Box;
385-
pub use alloc::collections::{btree_map, BTreeMap};
386-
pub use alloc::string::{String, ToString};
387-
pub use alloc::vec::{self, Vec};
388-
389-
#[cfg(feature = "std")]
390-
pub use std::error;
391-
}
392-
393-
////////////////////////////////////////////////////////////////////////////////
394-
395365
#[cfg(feature = "std")]
396366
#[doc(inline)]
397367
pub use crate::de::from_reader;
@@ -412,8 +382,8 @@ pub use crate::value::{from_value, to_value, Map, Number, Value};
412382
macro_rules! tri {
413383
($e:expr $(,)?) => {
414384
match $e {
415-
crate::lib::Result::Ok(val) => val,
416-
crate::lib::Result::Err(err) => return crate::lib::Result::Err(err),
385+
core::result::Result::Ok(val) => val,
386+
core::result::Result::Err(err) => return core::result::Result::Err(err),
417387
}
418388
};
419389
}

0 commit comments

Comments
 (0)