Skip to content

fix(serialize): Allow serialization of unsized types within Rc, Arc, and Cow #975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025
Merged
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
14 changes: 7 additions & 7 deletions serialize/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl<T: Send + Sync> CanonicalDeserialize for PhantomData<T> {
}
}

impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for Rc<T> {
impl<T: ?Sized + CanonicalSerialize + ToOwned> CanonicalSerialize for Rc<T> {
#[inline]
fn serialize_with_mode<W: Write>(
&self,
Expand All @@ -354,7 +354,7 @@ impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for Rc<T> {
}

#[cfg(target_has_atomic = "ptr")]
impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for ark_std::sync::Arc<T> {
impl<T: ?Sized + CanonicalSerialize + ToOwned> CanonicalSerialize for ark_std::sync::Arc<T> {
#[inline]
fn serialize_with_mode<W: Write>(
&self,
Expand All @@ -371,7 +371,7 @@ impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for ark_std::sync::Arc<
}

#[cfg(target_has_atomic = "ptr")]
impl<T: Valid + Sync + Send> Valid for ark_std::sync::Arc<T> {
impl<T: ?Sized + Valid + Sync + Send> Valid for ark_std::sync::Arc<T> {
#[inline]
fn check(&self) -> Result<(), SerializationError> {
self.as_ref().check()
Expand All @@ -389,7 +389,7 @@ impl<T: Valid + Sync + Send> Valid for ark_std::sync::Arc<T> {
}

#[cfg(target_has_atomic = "ptr")]
impl<T: CanonicalDeserialize + ToOwned + Sync + Send> CanonicalDeserialize
impl<T: ?Sized + CanonicalDeserialize + ToOwned + Sync + Send> CanonicalDeserialize
for ark_std::sync::Arc<T>
{
#[inline]
Expand All @@ -404,7 +404,7 @@ impl<T: CanonicalDeserialize + ToOwned + Sync + Send> CanonicalDeserialize
}
}

impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for Cow<'_, T> {
impl<T: ?Sized + CanonicalSerialize + ToOwned> CanonicalSerialize for Cow<'_, T> {
#[inline]
fn serialize_with_mode<W: Write>(
&self,
Expand All @@ -422,7 +422,7 @@ impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for Cow<'_, T> {

impl<T> Valid for Cow<'_, T>
where
T: ToOwned + Sync + Valid + Send,
T: ?Sized + ToOwned + Sync + Valid + Send,
<T as ToOwned>::Owned: CanonicalDeserialize + Send,
{
#[inline]
Expand All @@ -444,7 +444,7 @@ where

impl<T> CanonicalDeserialize for Cow<'_, T>
where
T: ToOwned + Valid + Sync + Send,
T: ?Sized + ToOwned + Valid + Sync + Send,
<T as ToOwned>::Owned: CanonicalDeserialize + Valid + Send,
{
#[inline]
Expand Down
Loading