Skip to content

Commit e695aa6

Browse files
authored
Merge pull request #78 from quartiq/heapless-0.8
bump heapless to 0.8
2 parents e82b4f3 + c73589d commit e695aa6

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
### Added
10+
### Added
1111

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

15+
### Changed
16+
17+
- `heapless` bumped to v0.8.
18+
1519
## [v0.5.1] - 2023-07-26
1620

1721
### Added

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ version = "0.5.1"
1616
ryu = "1.0.5"
1717

1818
[dependencies.heapless]
19-
version = "0.7"
19+
version = "0.8"
2020
optional = true
2121

2222
[dependencies.serde]

src/de/mod.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ where
757757

758758
#[cfg(test)]
759759
mod tests {
760+
use core::str::FromStr;
760761
use serde_derive::Deserialize;
761762

762763
#[derive(Debug, Deserialize, PartialEq)]
@@ -1083,7 +1084,10 @@ mod tests {
10831084
assert_eq!(
10841085
crate::from_str::<Xy>(r#"[10]"#),
10851086
Err(crate::de::Error::CustomErrorWithMessage(
1086-
"invalid length 1, expected tuple struct Xy with 2 elements".into()
1087+
heapless::String::from_str(
1088+
"invalid length 1, expected tuple struct Xy with 2 elements"
1089+
)
1090+
.unwrap()
10871091
))
10881092
);
10891093
assert_eq!(
@@ -1190,7 +1194,9 @@ mod tests {
11901194
use serde::de::Error;
11911195
assert_eq!(
11921196
crate::de::Error::custom("something bad happened"),
1193-
crate::de::Error::CustomErrorWithMessage("something bad happened".into())
1197+
crate::de::Error::CustomErrorWithMessage(
1198+
heapless::String::from_str("something bad happened").unwrap()
1199+
)
11941200
);
11951201
}
11961202

@@ -1200,8 +1206,8 @@ mod tests {
12001206
use serde::de::Error;
12011207
assert_eq!(
12021208
crate::de::Error::custom("0123456789012345678901234567890123456789012345678901234567890123 <- after here the message should be truncated"),
1203-
crate::de::Error::CustomErrorWithMessage(
1204-
"0123456789012345678901234567890123456789012345678901234567890123".into()
1209+
crate::de::Error::CustomErrorWithMessage(heapless::String::from_str(
1210+
"0123456789012345678901234567890123456789012345678901234567890123").unwrap()
12051211
)
12061212
);
12071213
}

src/ser/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ pub fn to_string<T, const N: usize>(value: &T) -> Result<String<N>>
448448
where
449449
T: ser::Serialize + ?Sized,
450450
{
451-
Ok(unsafe { str::from_utf8_unchecked(&to_vec::<T, N>(value)?) }.into())
451+
Ok(unsafe { String::from_utf8_unchecked(to_vec::<T, N>(value)?) })
452452
}
453453

454454
/// Serializes the given data structure as a JSON byte vector

0 commit comments

Comments
 (0)