Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ readme = "README.md"
authors = ["Emile Fugulin <code@efugulin.com>", "The Javy Project Developers"]

[dependencies]
rquickjs = "0.11"
serde = "1"
rquickjs = { version = "0.11", default-features = false }
serde = { version = "1", default-features = false, features = ["alloc"] }

[dev-dependencies]
quickcheck = "1"
Expand Down
5 changes: 4 additions & 1 deletion src/de.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use alloc::string::{String, ToString as _};
use alloc::vec::Vec;

use rquickjs::{
Exception, Filter, Function, Null, Object, String as JSString, Value,
atom::PredefinedAtom,
Expand Down Expand Up @@ -96,7 +99,7 @@ impl<'js> Deserializer<'js> {
if let Some(f64_representation) = self.value.as_float() {
let is_positive = f64_representation.is_sign_positive();
let safe_integer_range = (MIN_SAFE_INTEGER as f64)..=(MAX_SAFE_INTEGER as f64);
let whole = f64_representation.fract() == 0.0;
let whole = (f64_representation % 1.0) == 0.0;

if whole && is_positive && f64_representation <= u32::MAX as f64 {
return visitor.visit_u32(f64_representation as u32);
Expand Down
6 changes: 4 additions & 2 deletions src/err.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::{error, fmt};
use alloc::boxed::Box;
use alloc::string::{String, ToString as _};
use core::{error, fmt};

use rquickjs::{Ctx, Error as JSError, Exception, Value};
use serde::{de, ser};
Expand All @@ -18,7 +20,7 @@ impl Error {
}

/// Alias for a `Result` with the error type `rquickjs_serde::Error`.
pub type Result<T> = std::result::Result<T, Error>;
pub type Result<T> = core::result::Result<T, Error>;

impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#![cfg_attr(not(test), no_std)]

extern crate alloc;

use rquickjs::{Ctx, Value};
use serde::Serialize;
use serde::de::DeserializeOwned;
Expand Down
2 changes: 2 additions & 0 deletions src/ser.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::string::ToString as _;

use rquickjs::{Array, Ctx, Object, String as JSString, Value, object::Property};
use serde::{Serialize, ser};

Expand Down
5 changes: 3 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::str;
use alloc::string::String;
use core::str;

use rquickjs::{Ctx, Error as JSError, String as JSString, Value, qjs};

Expand Down Expand Up @@ -29,7 +30,7 @@ pub fn to_string_lossy<'js>(cx: &Ctx<'js>, string: &JSString<'js>, error: JSErro
(false).into(),
)
};
let buffer = unsafe { std::slice::from_raw_parts(ptr as *const u8, len as usize) };
let buffer = unsafe { core::slice::from_raw_parts(ptr as *const u8, len as usize) };

// The error here *must* be a Utf8 error; the `JSString::to_string()` may
// return `JSError::Unknown`, but at that point, something else has gone
Expand Down