From 35e172d6369794c6a81c9cd1bb249277e66e79c6 Mon Sep 17 00:00:00 2001 From: tjjfvi Date: Mon, 27 May 2024 16:22:26 -0400 Subject: [PATCH] make no_std --- Cargo.lock | 2 +- src/lib.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 19fe388..86a631d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "TSPL" -version = "0.0.10" +version = "0.0.12" dependencies = [ "highlight_error", ] diff --git a/src/lib.rs b/src/lib.rs index 6e51b66..128888c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,9 @@ +#![no_std] + +extern crate alloc; + +use alloc::{format, string::{String, ToString}}; + use highlight_error::{*}; #[macro_export] @@ -145,7 +151,7 @@ pub trait Parser<'i> { if name.is_empty() { self.expected("name") } else { - Ok(name.to_owned()) + Ok(name.to_string()) } } @@ -175,7 +181,7 @@ pub trait Parser<'i> { let codepoint_str = self.take_while(|c| c.is_digit(16)); self.consume("}")?; u32::from_str_radix(codepoint_str, 16) - .ok().and_then(std::char::from_u32) + .ok().and_then(core::char::from_u32) .ok_or_else(|| self.expected::("unicode-codepoint").unwrap_err()) } Some('0') => Ok('\0'),