From 671a3002a2b7003c9bad93556e7a69cbc9f1fa1c Mon Sep 17 00:00:00 2001 From: Able Date: Wed, 4 Dec 2024 02:36:09 -0600 Subject: [PATCH] port to no_std --- Cargo.lock | 25 +++++++++++++++++++++++++ Cargo.toml | 4 ++++ src/lib/mod.rs | 11 ++++++++--- src/main.rs | 3 +++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5cda058..8b79dea 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,31 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "foldhash", + "rustc-std-workspace-alloc", +] + [[package]] name = "rlisp" version = "0.1.0" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "rustc-std-workspace-alloc" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d441c3b2ebf55cebf796bfdc265d67fa09db17b7bb6bd4be75c509e1e8fec3" diff --git a/Cargo.toml b/Cargo.toml index 14b5d43..11d78bd 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +hashbrown = { version = "0.15", default-features = false, features = [ + "alloc", + "default-hasher", +] } diff --git a/src/lib/mod.rs b/src/lib/mod.rs index ff7ced6..c1e848e 100755 --- a/src/lib/mod.rs +++ b/src/lib/mod.rs @@ -1,7 +1,12 @@ -use core::num::ParseFloatError; -use std::fmt; +use core::fmt; + +use core::num::ParseFloatError; +// use std::hash::DefaultHasher; + +extern crate alloc; + +pub use hashbrown::hash_map::HashMap; -pub use std::collections::HashMap; pub use std::io::Write; pub use std::rc::Rc; diff --git a/src/main.rs b/src/main.rs index 266225b..ed72326 100755 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@ #![feature(slice_take)] #![allow(special_module_name)] +#![feature(build_hasher_default_const_new)] +// #![no_std] + use std::io; use std::io::Write;