Skip to content

Conversation

@fitzgen
Copy link
Member

@fitzgen fitzgen commented Feb 10, 2026

Depends on #12562

@fitzgen fitzgen requested a review from a team as a code owner February 10, 2026 22:16
@fitzgen fitzgen requested review from alexcrichton and removed request for a team February 10, 2026 22:16
Comment on lines +231 to +248
impl serde::ser::Serialize for Atom {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serde::ser::Serialize::serialize(&self.index, serializer)
}
}

impl<'de> serde::de::Deserialize<'de> for Atom {
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let index = serde::de::Deserialize::deserialize(deserializer)?;
Ok(Self { index })
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can be #[derive]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've generally been avoiding derives to avoid the compile time hit -- not worth it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no that seems pretty reasonable yeah. There are so few derive-compatible-impls in this crate I think it's reasonable to avoid for that reason


while let Some(s) = seq.next_element::<String>()? {
debug_assert_eq!(s.len(), s.capacity());
let s = s.into_boxed_str().expect("len == cap");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I'd say that this should use ? since while postcard might provide this guarantee a future deserializer might not, so in the spirit of being relatively flexible in core data structures I think it'd be good to propagate the error instead of assert here.

I also feel like it's conventionally a bit easier to reason about "always use ?" and sometimes there's a reserve for performance. Otherwise all .expect(...) needs to be double-checked against some reserve or some other condition nearby which can be a bit confusing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while postcard might provide this guarantee a future deserializer might not

It is our own implementation of Deserialize for wasmtime_core::alloc::String that provides this guarantee. Does that change the calculus for you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose a bit, but in general I still feel like I'd lean towards ?-and-forget. I don't think there's any reasonable way we can expect everyone to keep all the various constraints in their heads about reservation/capacity/etc and it's far easier to just use ? on methods. If the ? is dynamically dead that doesn't seem any worse to me than .expect("...") being dynamically dead

@github-actions github-actions bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants