Skip to content

Commit

Permalink
start, upgrade rkyv to v0.8
Browse files Browse the repository at this point in the history
* upgrades rkyv to v0.8
* makes necessary changes to the impl
  • Loading branch information
ParkMyCar committed Sep 14, 2024
1 parent 193d13e commit 0d75c8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compact_str/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ diesel = { version = "2", optional = true, default-features = false }
markup = { version = "0.13", optional = true, default-features = false }
proptest = { version = "1", optional = true, default-features = false, features = ["std"] }
quickcheck = { version = "1", optional = true, default-features = false }
rkyv = { version = "0.7", optional = true, default-features = false, features = ["size_32"] }
rkyv = { version = "0.8", optional = true, default-features = false }
serde = { version = "1", optional = true, default-features = false, features = ["derive", "alloc"] }
smallvec = { version = "1", optional = true, features = ["union"] }
sqlx = { version = "0.7", optional = true, default-features = false }
Expand Down
11 changes: 8 additions & 3 deletions compact_str/src/features/rkyv.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#![cfg_attr(docsrs, doc(cfg(feature = "rkyv")))]

use rkyv::rancor::{
Fallible,
Source,
};
use rkyv::string::{
ArchivedString,
StringResolver,
Expand All @@ -8,7 +12,7 @@ use rkyv::{
Archive,
Deserialize,
DeserializeUnsized,
Fallible,
Place,
Serialize,
SerializeUnsized,
};
Expand All @@ -20,14 +24,15 @@ impl Archive for CompactString {
type Resolver = StringResolver;

#[inline]
unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) {
ArchivedString::resolve_from_str(self.as_str(), pos, resolver, out);
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>) {
ArchivedString::resolve_from_str(self.as_str(), resolver, out);
}
}

impl<S: Fallible + ?Sized> Serialize<S> for CompactString
where
str: SerializeUnsized<S>,
S::Error: Source,
{
#[inline]
fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error> {
Expand Down

0 comments on commit 0d75c8f

Please sign in to comment.