Skip to content

Commit

Permalink
Fix usage of std instead of core
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte committed Jun 18, 2020
1 parent ed4ab89 commit d6f6dab
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{
use core::{
fmt::{self, Debug, Display, Formatter},
num::ParseIntError as StdParseIntError,
};
Expand Down
8 changes: 4 additions & 4 deletions src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Int {
/// Basic usage:
///
/// ```
/// # use {std::convert::TryFrom, js_int::Int};
/// # use {core::convert::TryFrom, js_int::Int};
/// assert_eq!(Int::MIN, Int::try_from(-9_007_199_254_740_991i64).unwrap());
/// ```
pub const MIN: Self = Self(MIN_SAFE_INT);
Expand All @@ -46,7 +46,7 @@ impl Int {
/// Basic usage:
///
/// ```
/// # use {std::convert::TryFrom, js_int::Int};
/// # use {core::convert::TryFrom, js_int::Int};
/// assert_eq!(Int::MAX, Int::try_from(9_007_199_254_740_991i64).unwrap());
/// ```
pub const MAX: Self = Self(MAX_SAFE_INT);
Expand Down Expand Up @@ -150,7 +150,7 @@ impl Int {
/// Basic usage:
///
/// ```
/// # use {std::convert::TryFrom, js_int::Int};
/// # use {core::convert::TryFrom, js_int::Int};
/// assert_eq!(Int::min_value(), Int::try_from(-9_007_199_254_740_991i64).unwrap());
/// ```
#[must_use]
Expand All @@ -166,7 +166,7 @@ impl Int {
/// Basic usage:
///
/// ```
/// # use {std::convert::TryFrom, js_int::Int};
/// # use {core::convert::TryFrom, js_int::Int};
/// assert_eq!(Int::max_value(), Int::try_from(9_007_199_254_740_991i64).unwrap());
/// ```
#[must_use]
Expand Down
46 changes: 23 additions & 23 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
#[macro_export]
macro_rules! int {
($n:literal) => {
<$crate::Int as ::std::convert::From<i32>>::from($n)
<$crate::Int as ::core::convert::From<i32>>::from($n)
};
}

/// Creates a `UInt` from a numeric literal.
#[macro_export]
macro_rules! uint {
($n:literal) => {
<$crate::UInt as ::std::convert::From<u32>>::from($n)
<$crate::UInt as ::core::convert::From<u32>>::from($n)
};
}

macro_rules! fmt_impls {
($type:ident) => {
impl ::std::fmt::Display for $type {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
impl ::core::fmt::Display for $type {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
write!(f, "{}", self.0)
}
}

impl ::std::fmt::Debug for $type {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
impl ::core::fmt::Debug for $type {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
write!(f, "{:?}", self.0)
}
}
Expand All @@ -32,33 +32,33 @@ macro_rules! fmt_impls {

macro_rules! convert_impls {
($type:ident, $t8:ident, $t16:ident, $t32:ident, $t64:ident, $t128:ident) => {
impl ::std::convert::From<$t8> for $type {
impl ::core::convert::From<$t8> for $type {
fn from(val: $t8) -> Self {
Self($t64::from(val))
}
}

impl ::std::convert::From<$t16> for $type {
impl ::core::convert::From<$t16> for $type {
fn from(val: $t16) -> Self {
Self($t64::from(val))
}
}

impl ::std::convert::From<$t32> for $type {
impl ::core::convert::From<$t32> for $type {
fn from(val: $t32) -> Self {
Self($t64::from(val))
}
}

impl ::std::convert::TryFrom<$t64> for $type {
impl ::core::convert::TryFrom<$t64> for $type {
type Error = crate::error::TryFromIntError;

fn try_from(val: $t64) -> Result<Self, crate::error::TryFromIntError> {
Self::new(val).ok_or_else(crate::error::TryFromIntError::new)
}
}

impl ::std::convert::TryFrom<$t128> for $type {
impl ::core::convert::TryFrom<$t128> for $type {
type Error = crate::error::TryFromIntError;

fn try_from(val: $t128) -> Result<Self, crate::error::TryFromIntError> {
Expand All @@ -68,43 +68,43 @@ macro_rules! convert_impls {
}
}

impl ::std::convert::TryFrom<$type> for $t8 {
type Error = ::std::num::TryFromIntError;
impl ::core::convert::TryFrom<$type> for $t8 {
type Error = ::core::num::TryFromIntError;

fn try_from(val: $type) -> Result<Self, ::std::num::TryFromIntError> {
fn try_from(val: $type) -> Result<Self, ::core::num::TryFromIntError> {
Self::try_from(val.0)
}
}

impl ::std::convert::TryFrom<$type> for $t16 {
type Error = ::std::num::TryFromIntError;
impl ::core::convert::TryFrom<$type> for $t16 {
type Error = ::core::num::TryFromIntError;

fn try_from(val: $type) -> Result<Self, ::std::num::TryFromIntError> {
fn try_from(val: $type) -> Result<Self, ::core::num::TryFromIntError> {
Self::try_from(val.0)
}
}

impl ::std::convert::TryFrom<$type> for $t32 {
type Error = ::std::num::TryFromIntError;
impl ::core::convert::TryFrom<$type> for $t32 {
type Error = ::core::num::TryFromIntError;

fn try_from(val: $type) -> Result<Self, ::std::num::TryFromIntError> {
fn try_from(val: $type) -> Result<Self, ::core::num::TryFromIntError> {
Self::try_from(val.0)
}
}

impl ::std::convert::From<$type> for $t64 {
impl ::core::convert::From<$type> for $t64 {
fn from(val: $type) -> Self {
val.0
}
}

impl ::std::convert::From<$type> for $t128 {
impl ::core::convert::From<$type> for $t128 {
fn from(val: $type) -> Self {
$t128::from(val.0)
}
}

impl ::std::convert::From<$type> for f64 {
impl ::core::convert::From<$type> for f64 {
fn from(val: $type) -> Self {
val.0 as f64
}
Expand Down
4 changes: 2 additions & 2 deletions src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl UInt {
/// Basic usage:
///
/// ```
/// # use {std::convert::TryFrom, js_int::UInt};
/// # use {core::convert::TryFrom, js_int::UInt};
/// assert_eq!(UInt::MAX, UInt::try_from(9_007_199_254_740_991u64).unwrap());
/// ```
pub const MAX: Self = Self(MAX_SAFE_UINT);
Expand Down Expand Up @@ -144,7 +144,7 @@ impl UInt {
/// Basic usage:
///
/// ```
/// # use {std::convert::TryFrom, js_int::UInt};
/// # use {core::convert::TryFrom, js_int::UInt};
/// assert_eq!(UInt::max_value(), UInt::try_from(9_007_199_254_740_991u64).unwrap());
/// ```
#[must_use]
Expand Down

0 comments on commit d6f6dab

Please sign in to comment.