Skip to content

Commit

Permalink
Merge pull request #78 from quartiq/heapless-0.8
Browse files Browse the repository at this point in the history
bump heapless to 0.8
  • Loading branch information
ryan-summers committed Nov 13, 2023
2 parents e82b4f3 + c73589d commit e695aa6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added
### Added

- Support for optional package `defmt` which allows for easy conversion for
error types when using tools like `probe-rs` for logging over debuggers.

### Changed

- `heapless` bumped to v0.8.

## [v0.5.1] - 2023-07-26

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ version = "0.5.1"
ryu = "1.0.5"

[dependencies.heapless]
version = "0.7"
version = "0.8"
optional = true

[dependencies.serde]
Expand Down
14 changes: 10 additions & 4 deletions src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ where

#[cfg(test)]
mod tests {
use core::str::FromStr;
use serde_derive::Deserialize;

#[derive(Debug, Deserialize, PartialEq)]
Expand Down Expand Up @@ -1083,7 +1084,10 @@ mod tests {
assert_eq!(
crate::from_str::<Xy>(r#"[10]"#),
Err(crate::de::Error::CustomErrorWithMessage(
"invalid length 1, expected tuple struct Xy with 2 elements".into()
heapless::String::from_str(
"invalid length 1, expected tuple struct Xy with 2 elements"
)
.unwrap()
))
);
assert_eq!(
Expand Down Expand Up @@ -1190,7 +1194,9 @@ mod tests {
use serde::de::Error;
assert_eq!(
crate::de::Error::custom("something bad happened"),
crate::de::Error::CustomErrorWithMessage("something bad happened".into())
crate::de::Error::CustomErrorWithMessage(
heapless::String::from_str("something bad happened").unwrap()
)
);
}

Expand All @@ -1200,8 +1206,8 @@ mod tests {
use serde::de::Error;
assert_eq!(
crate::de::Error::custom("0123456789012345678901234567890123456789012345678901234567890123 <- after here the message should be truncated"),
crate::de::Error::CustomErrorWithMessage(
"0123456789012345678901234567890123456789012345678901234567890123".into()
crate::de::Error::CustomErrorWithMessage(heapless::String::from_str(
"0123456789012345678901234567890123456789012345678901234567890123").unwrap()
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ pub fn to_string<T, const N: usize>(value: &T) -> Result<String<N>>
where
T: ser::Serialize + ?Sized,
{
Ok(unsafe { str::from_utf8_unchecked(&to_vec::<T, N>(value)?) }.into())
Ok(unsafe { String::from_utf8_unchecked(to_vec::<T, N>(value)?) })
}

/// Serializes the given data structure as a JSON byte vector
Expand Down

0 comments on commit e695aa6

Please sign in to comment.