Skip to content
Closed
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
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ repository = "https://japaric.github.io/serde-json-core/serde_json_core"
version = "0.0.1"

[dependencies]
heapless = "0.4.0"
heapless = "0.5.1"

[dependencies.serde]
default-features = false
version = "1.0.80"
version = "1.0.102"

[dev-dependencies]
serde_derive = "1.0.80"
serde_derive = "1.0.102"

[features]
std = ["serde/std"]
std = ["serde/std"]
5 changes: 1 addition & 4 deletions src/de/enum_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use serde::de;

use crate::de::{Deserializer, Error, Result};

pub(crate) struct UnitVariantAccess<'a, 'b>
where
'b: 'a,
{
pub(crate) struct UnitVariantAccess<'a, 'b> {
de: &'a mut Deserializer<'b>,
}

Expand Down
10 changes: 2 additions & 8 deletions src/de/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use serde::de::{self, Visitor};

use crate::de::{Deserializer, Error};

pub struct MapAccess<'a, 'b>
where
'b: 'a,
{
pub struct MapAccess<'a, 'b> {
de: &'a mut Deserializer<'b>,
first: bool,
}
Expand Down Expand Up @@ -60,10 +57,7 @@ impl<'a, 'de> de::MapAccess<'de> for MapAccess<'a, 'de> {
}
}

struct MapKey<'a, 'b>
where
'b: 'a,
{
struct MapKey<'a, 'b> {
de: &'a mut Deserializer<'b>,
}

Expand Down
5 changes: 1 addition & 4 deletions src/de/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use serde::de;

use crate::de::{Deserializer, Error, Result};

pub(crate) struct SeqAccess<'a, 'b>
where
'b: 'a,
{
pub(crate) struct SeqAccess<'a, 'b> {
first: bool,
de: &'a mut Deserializer<'b>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#![deny(rust_2018_compatibility)]
#![deny(rust_2018_idioms)]
#![deny(warnings)]
#![no_std]
#![cfg_attr(not(feature = "std"), no_std)]

pub mod de;
pub mod ser;
Expand Down
20 changes: 13 additions & 7 deletions src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ where
// which take 200+ bytes of ROM / Flash
macro_rules! serialize_unsigned {
($self:ident, $N:expr, $v:expr) => {{
let mut buf: [u8; $N] = unsafe { mem::uninitialized() };
let mut buf: [mem::MaybeUninit<u8>; $N] =
unsafe { mem::MaybeUninit::uninit().assume_init() };

let mut v = $v;
let mut i = $N - 1;
loop {
buf[i] = (v % 10) as u8 + b'0';
buf[i] = mem::MaybeUninit::new((v % 10) as u8 + b'0');
v /= 10;

if v == 0 {
Expand All @@ -84,7 +85,9 @@ macro_rules! serialize_unsigned {
}
}

$self.buf.extend_from_slice(&buf[i..])?;
$self
.buf
.extend_from_slice(unsafe { mem::transmute::<_, &[u8]>(&buf[i..]) })?;
Ok(())
}};
}
Expand All @@ -100,10 +103,11 @@ macro_rules! serialize_signed {
(false, v as $uxx)
};

let mut buf: [u8; $N] = unsafe { mem::uninitialized() };
let mut buf: [mem::MaybeUninit<u8>; $N] =
unsafe { mem::MaybeUninit::uninit().assume_init() };
let mut i = $N - 1;
loop {
buf[i] = (v % 10) as u8 + b'0';
buf[i] = mem::MaybeUninit::new((v % 10) as u8 + b'0');
v /= 10;

i -= 1;
Expand All @@ -114,11 +118,13 @@ macro_rules! serialize_signed {
}

if signed {
buf[i] = b'-';
buf[i] = mem::MaybeUninit::new(b'-');
} else {
i += 1;
}
$self.buf.extend_from_slice(&buf[i..])?;
$self
.buf
.extend_from_slice(unsafe { mem::transmute::<_, &[u8]>(&buf[i..]) })?;
Ok(())
}};
}
Expand Down