Skip to content
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

Consider removing O type parameter of serialize_with_flavor #103

Open
dtolnay opened this issue Jul 5, 2023 · 2 comments
Open

Consider removing O type parameter of serialize_with_flavor #103

dtolnay opened this issue Jul 5, 2023 · 2 comments
Labels
postcard-2.0 Tracking issues for an eventual 2.0 version of the postcard wire format (not currently planned)

Comments

@dtolnay
Copy link
Contributor

dtolnay commented Jul 5, 2023

postcard::serialize_with_flavor is written in an odd way that makes the caller restate the Flavor's Output type explicitly when using turbofish.

postcard/src/ser/mod.rs

Lines 367 to 370 in a0ef8a2

pub fn serialize_with_flavor<T, S, O>(value: &T, storage: S) -> Result<O>
where
T: Serialize + ?Sized,
S: Flavor<Output = O>,

- pub fn serialize_with_flavor<T, S, O>(value: &T, storage: S) -> Result<O>
+ pub fn serialize_with_flavor<T, S>(value: &T, storage: S) -> Result<S::Output>
  where
      T: Serialize + ?Sized,
-     S: Flavor<Output = O>,
+     S: Flavor,
@dtolnay
Copy link
Contributor Author

dtolnay commented Jul 5, 2023

I can't tell whether this was a stylistic choice or oversight. My preference is for serialize_with_flavor::<T, Cobs<Slice<'a>>>(...) over serialize_with_flavor::<T, Cobs<Slice<'a>>, &'a mut [u8]>(...), but I can see there may be valid preferences in the other direction.

@jamesmunns
Copy link
Owner

As far as I can tell - this was likely an oversight, probably an artifact implementing flavors and never stepping back and realizing that those (always?) are the same type.

I do think this would be a breaking change as you noted in #105, but I'm tagging it with the 2.0 label so I don't forget to clean this up on the next major release.

@jamesmunns jamesmunns added the postcard-2.0 Tracking issues for an eventual 2.0 version of the postcard wire format (not currently planned) label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
postcard-2.0 Tracking issues for an eventual 2.0 version of the postcard wire format (not currently planned)
Projects
None yet
Development

No branches or pull requests

2 participants