From 4103e1c2bee2b0642d0601aebe989642e0d9c926 Mon Sep 17 00:00:00 2001 From: Hantong Chen Date: Mon, 24 Nov 2025 02:13:03 +0800 Subject: [PATCH] refactor: `no_std` support --- src/lib.rs | 14 +++++++++++--- src/u256.rs | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f59af63..751eb24 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,15 +21,23 @@ unsafe_code )] #![warn(rust_2018_idioms)] +#![no_std] + +extern crate alloc; + +#[cfg(test)] +extern crate std; mod u256; -use std::{ +use alloc::{ collections::{BTreeMap, BTreeSet, VecDeque}, - ops::RangeFrom, + vec, + vec::Vec, }; +use core::ops::RangeFrom; -use u256::U256; +use self::u256::U256; #[derive(Debug, Clone)] #[repr(transparent)] diff --git a/src/u256.rs b/src/u256.rs index bfee984..48b76d6 100644 --- a/src/u256.rs +++ b/src/u256.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::{ +use core::{ cmp::Ordering, ops::{ Add, AddAssign, BitAnd, BitOrAssign, Shl, ShlAssign, Sub, SubAssign,