This is an automated email from the ASF dual-hosted git repository. chaokunyang pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/fory-site.git
commit ad0092aa7a2fc5d04caa55bd55ac8a965eccc193 Author: chaokunyang <[email protected]> AuthorDate: Sun Jul 26 16:15:33 2026 +0000 🔄 synced local 'docs/compiler/' with remote 'docs/compiler/' --- docs/compiler/generated-code.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/compiler/generated-code.md b/docs/compiler/generated-code.md index 68fddf234c..5dbe6b6f99 100644 --- a/docs/compiler/generated-code.md +++ b/docs/compiler/generated-code.md @@ -430,8 +430,9 @@ Unions map to Rust enums with `#[fory(id = ...)]` schema case attributes. forward-compatibility carrier. The marker only selects the carrier and does not add an entry to the schema case table; schema cases still use the full `0..N` ID range. A generated typed union must have at least one non-`Unknown` case. The -compiler marks the first declared non-`Unknown` case as `#[fory(default)]` and -emits `Default` from that case: +compiler marks the first declared non-`Unknown` case as `#[fory(default)]`. +When that case's payload implements Rust's standard `Default` trait, the +compiler also emits a standard `Default` implementation from that case: ```rust #[derive(::fory::ForyUnion, Clone, Debug, PartialEq, Eq, Hash)] @@ -446,11 +447,17 @@ pub enum Animal { impl ::std::default::Default for Animal { fn default() -> Self { - Self::Dog(<self::Dog as ::fory::ForyDefault>::fory_default()) + Self::Dog(<self::Dog as ::std::default::Default>::default()) } } ``` +If the selected payload does not implement standard `Default`, such as an +`any` payload, the generated union has no infallible `Default` +implementation. This model-level default is independent of Fory's fallible +deserialization default, which reconstructs the selected case through its +codecs and active read context. + Nested types generate nested modules: ```rust --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
