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

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed May 4, 2021
1 parent 72b7e3b commit 737da43
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
#[cfg(any(test, feature="std"))] pub extern crate core;
#[cfg(feature="serde")] pub extern crate serde;
#[cfg(all(test,feature="serde"))] extern crate serde_test;
///a
pub mod export {
/// b
pub mod core {
///c
pub use ::core::*; } }

#[cfg(feature = "schemars")] extern crate schemars;

Expand Down
36 changes: 18 additions & 18 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ macro_rules! hex_fmt_impl(
hex_fmt_impl!($imp, $ty, );
);
($imp:ident, $ty:ident, $($gen:ident: $gent:ident),*) => (
impl<$($gen: $gent),*> $crate::core::fmt::$imp for $ty<$($gen),*> {
fn fmt(&self, f: &mut $crate::core::fmt::Formatter) -> $crate::core::fmt::Result {
impl<$($gen: $gent),*> $crate::export::core::fmt::$imp for $ty<$($gen),*> {
fn fmt(&self, f: &mut $crate::export::core::fmt::Formatter) -> $crate::export::core::fmt::Result {
use $crate::hex::{format_hex, format_hex_reverse};
if $ty::<$($gen),*>::DISPLAY_BACKWARD {
format_hex_reverse(&self.0, f)
Expand All @@ -49,37 +49,37 @@ macro_rules! index_impl(
index_impl!($ty, );
);
($ty:ident, $($gen:ident: $gent:ident),*) => (
impl<$($gen: $gent),*> $crate::core::ops::Index<usize> for $ty<$($gen),*> {
impl<$($gen: $gent),*> $crate::export::core::ops::Index<usize> for $ty<$($gen),*> {
type Output = u8;
fn index(&self, index: usize) -> &u8 {
&self.0[index]
}
}

impl<$($gen: $gent),*> $crate::core::ops::Index<$crate::core::ops::Range<usize>> for $ty<$($gen),*> {
impl<$($gen: $gent),*> $crate::export::core::ops::Index<$crate::export::core::ops::Range<usize>> for $ty<$($gen),*> {
type Output = [u8];
fn index(&self, index: $crate::core::ops::Range<usize>) -> &[u8] {
fn index(&self, index: $crate::export::core::ops::Range<usize>) -> &[u8] {
&self.0[index]
}
}

impl<$($gen: $gent),*> $crate::core::ops::Index<$crate::core::ops::RangeFrom<usize>> for $ty<$($gen),*> {
impl<$($gen: $gent),*> $crate::export::core::ops::Index<$crate::export::core::ops::RangeFrom<usize>> for $ty<$($gen),*> {
type Output = [u8];
fn index(&self, index: $crate::core::ops::RangeFrom<usize>) -> &[u8] {
fn index(&self, index: $crate::export::core::ops::RangeFrom<usize>) -> &[u8] {
&self.0[index]
}
}

impl<$($gen: $gent),*> $crate::core::ops::Index<$crate::core::ops::RangeTo<usize>> for $ty<$($gen),*> {
impl<$($gen: $gent),*> $crate::export::core::ops::Index<$crate::export::core::ops::RangeTo<usize>> for $ty<$($gen),*> {
type Output = [u8];
fn index(&self, index: $crate::core::ops::RangeTo<usize>) -> &[u8] {
fn index(&self, index: $crate::export::core::ops::RangeTo<usize>) -> &[u8] {
&self.0[index]
}
}

impl<$($gen: $gent),*> $crate::core::ops::Index<$crate::core::ops::RangeFull> for $ty<$($gen),*> {
impl<$($gen: $gent),*> $crate::export::core::ops::Index<$crate::export::core::ops::RangeFull> for $ty<$($gen),*> {
type Output = [u8];
fn index(&self, index: $crate::core::ops::RangeFull) -> &[u8] {
fn index(&self, index: $crate::export::core::ops::RangeFull) -> &[u8] {
&self.0[index]
}
}
Expand All @@ -93,19 +93,19 @@ macro_rules! borrow_slice_impl(
borrow_slice_impl!($ty, );
);
($ty:ident, $($gen:ident: $gent:ident),*) => (
impl<$($gen: $gent),*> $crate::core::borrow::Borrow<[u8]> for $ty<$($gen),*> {
impl<$($gen: $gent),*> $crate::export::core::borrow::Borrow<[u8]> for $ty<$($gen),*> {
fn borrow(&self) -> &[u8] {
&self[..]
}
}

impl<$($gen: $gent),*> $crate::core::convert::AsRef<[u8]> for $ty<$($gen),*> {
impl<$($gen: $gent),*> $crate::export::core::convert::AsRef<[u8]> for $ty<$($gen),*> {
fn as_ref(&self) -> &[u8] {
&self[..]
}
}

impl<$($gen: $gent),*> $crate::core::ops::Deref for $ty<$($gen),*> {
impl<$($gen: $gent),*> $crate::export::core::ops::Deref for $ty<$($gen),*> {
type Target = [u8];

fn deref(&self) -> &Self::Target {
Expand Down Expand Up @@ -241,14 +241,14 @@ macro_rules! hash_newtype {
}
}

impl ::core::convert::From<$hash> for $newtype {
impl $crate::export::core::convert::From<$hash> for $newtype {
fn from(inner: $hash) -> $newtype {
// Due to rust 1.22 we have to use this instead of simple `Self(inner)`
Self { 0: inner }
}
}

impl ::core::convert::From<$newtype> for $hash {
impl $crate::export::core::convert::From<$newtype> for $hash {
fn from(hashtype: $newtype) -> $hash {
hashtype.0
}
Expand Down Expand Up @@ -290,9 +290,9 @@ macro_rules! hash_newtype {
}
}

impl ::core::str::FromStr for $newtype {
impl $crate::export::core::str::FromStr for $newtype {
type Err = $crate::hex::Error;
fn from_str(s: &str) -> ::core::result::Result<$newtype, Self::Err> {
fn from_str(s: &str) -> $crate::export::core::result::Result<$newtype, Self::Err> {
$crate::hex::FromHex::from_hex(s)
}
}
Expand Down

0 comments on commit 737da43

Please sign in to comment.