Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit f6f5b01

Browse files
committed
Re-export core as _export::_core both in std and no_std modes
1 parent 72b7e3b commit f6f5b01

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,18 @@
3737
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
3838
#[cfg(all(test, feature = "unstable"))] extern crate test;
3939

40-
#[cfg(any(test, feature="std"))] pub extern crate core;
40+
#[cfg(any(test, feature="std"))] extern crate core;
4141
#[cfg(feature="serde")] pub extern crate serde;
4242
#[cfg(all(test,feature="serde"))] extern crate serde_test;
4343

44+
#[doc(hidden)]
45+
pub mod _export {
46+
/// A re-export of ::core::*
47+
pub mod _core {
48+
pub use ::core::*;
49+
}
50+
}
51+
4452
#[cfg(feature = "schemars")] extern crate schemars;
4553

4654
#[macro_use] mod util;

src/util.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ macro_rules! hex_fmt_impl(
2929
hex_fmt_impl!($imp, $ty, );
3030
);
3131
($imp:ident, $ty:ident, $($gen:ident: $gent:ident),*) => (
32-
impl<$($gen: $gent),*> $crate::core::fmt::$imp for $ty<$($gen),*> {
33-
fn fmt(&self, f: &mut $crate::core::fmt::Formatter) -> $crate::core::fmt::Result {
32+
impl<$($gen: $gent),*> $crate::_export::_core::fmt::$imp for $ty<$($gen),*> {
33+
fn fmt(&self, f: &mut $crate::_export::_core::fmt::Formatter) -> $crate::_export::_core::fmt::Result {
3434
use $crate::hex::{format_hex, format_hex_reverse};
3535
if $ty::<$($gen),*>::DISPLAY_BACKWARD {
3636
format_hex_reverse(&self.0, f)
@@ -49,37 +49,37 @@ macro_rules! index_impl(
4949
index_impl!($ty, );
5050
);
5151
($ty:ident, $($gen:ident: $gent:ident),*) => (
52-
impl<$($gen: $gent),*> $crate::core::ops::Index<usize> for $ty<$($gen),*> {
52+
impl<$($gen: $gent),*> $crate::_export::_core::ops::Index<usize> for $ty<$($gen),*> {
5353
type Output = u8;
5454
fn index(&self, index: usize) -> &u8 {
5555
&self.0[index]
5656
}
5757
}
5858

59-
impl<$($gen: $gent),*> $crate::core::ops::Index<$crate::core::ops::Range<usize>> for $ty<$($gen),*> {
59+
impl<$($gen: $gent),*> $crate::_export::_core::ops::Index<$crate::_export::_core::ops::Range<usize>> for $ty<$($gen),*> {
6060
type Output = [u8];
61-
fn index(&self, index: $crate::core::ops::Range<usize>) -> &[u8] {
61+
fn index(&self, index: $crate::_export::_core::ops::Range<usize>) -> &[u8] {
6262
&self.0[index]
6363
}
6464
}
6565

66-
impl<$($gen: $gent),*> $crate::core::ops::Index<$crate::core::ops::RangeFrom<usize>> for $ty<$($gen),*> {
66+
impl<$($gen: $gent),*> $crate::_export::_core::ops::Index<$crate::_export::_core::ops::RangeFrom<usize>> for $ty<$($gen),*> {
6767
type Output = [u8];
68-
fn index(&self, index: $crate::core::ops::RangeFrom<usize>) -> &[u8] {
68+
fn index(&self, index: $crate::_export::_core::ops::RangeFrom<usize>) -> &[u8] {
6969
&self.0[index]
7070
}
7171
}
7272

73-
impl<$($gen: $gent),*> $crate::core::ops::Index<$crate::core::ops::RangeTo<usize>> for $ty<$($gen),*> {
73+
impl<$($gen: $gent),*> $crate::_export::_core::ops::Index<$crate::_export::_core::ops::RangeTo<usize>> for $ty<$($gen),*> {
7474
type Output = [u8];
75-
fn index(&self, index: $crate::core::ops::RangeTo<usize>) -> &[u8] {
75+
fn index(&self, index: $crate::_export::_core::ops::RangeTo<usize>) -> &[u8] {
7676
&self.0[index]
7777
}
7878
}
7979

80-
impl<$($gen: $gent),*> $crate::core::ops::Index<$crate::core::ops::RangeFull> for $ty<$($gen),*> {
80+
impl<$($gen: $gent),*> $crate::_export::_core::ops::Index<$crate::_export::_core::ops::RangeFull> for $ty<$($gen),*> {
8181
type Output = [u8];
82-
fn index(&self, index: $crate::core::ops::RangeFull) -> &[u8] {
82+
fn index(&self, index: $crate::_export::_core::ops::RangeFull) -> &[u8] {
8383
&self.0[index]
8484
}
8585
}
@@ -93,19 +93,19 @@ macro_rules! borrow_slice_impl(
9393
borrow_slice_impl!($ty, );
9494
);
9595
($ty:ident, $($gen:ident: $gent:ident),*) => (
96-
impl<$($gen: $gent),*> $crate::core::borrow::Borrow<[u8]> for $ty<$($gen),*> {
96+
impl<$($gen: $gent),*> $crate::_export::_core::borrow::Borrow<[u8]> for $ty<$($gen),*> {
9797
fn borrow(&self) -> &[u8] {
9898
&self[..]
9999
}
100100
}
101101

102-
impl<$($gen: $gent),*> $crate::core::convert::AsRef<[u8]> for $ty<$($gen),*> {
102+
impl<$($gen: $gent),*> $crate::_export::_core::convert::AsRef<[u8]> for $ty<$($gen),*> {
103103
fn as_ref(&self) -> &[u8] {
104104
&self[..]
105105
}
106106
}
107107

108-
impl<$($gen: $gent),*> $crate::core::ops::Deref for $ty<$($gen),*> {
108+
impl<$($gen: $gent),*> $crate::_export::_core::ops::Deref for $ty<$($gen),*> {
109109
type Target = [u8];
110110

111111
fn deref(&self) -> &Self::Target {
@@ -241,14 +241,14 @@ macro_rules! hash_newtype {
241241
}
242242
}
243243

244-
impl ::core::convert::From<$hash> for $newtype {
244+
impl $crate::_export::_core::convert::From<$hash> for $newtype {
245245
fn from(inner: $hash) -> $newtype {
246246
// Due to rust 1.22 we have to use this instead of simple `Self(inner)`
247247
Self { 0: inner }
248248
}
249249
}
250250

251-
impl ::core::convert::From<$newtype> for $hash {
251+
impl $crate::_export::_core::convert::From<$newtype> for $hash {
252252
fn from(hashtype: $newtype) -> $hash {
253253
hashtype.0
254254
}
@@ -290,9 +290,9 @@ macro_rules! hash_newtype {
290290
}
291291
}
292292

293-
impl ::core::str::FromStr for $newtype {
293+
impl $crate::_export::_core::str::FromStr for $newtype {
294294
type Err = $crate::hex::Error;
295-
fn from_str(s: &str) -> ::core::result::Result<$newtype, Self::Err> {
295+
fn from_str(s: &str) -> $crate::_export::_core::result::Result<$newtype, Self::Err> {
296296
$crate::hex::FromHex::from_hex(s)
297297
}
298298
}

0 commit comments

Comments
 (0)