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
The following commit(s) were added to refs/heads/main by this push:
new 28e9d98c3 🔄 synced local 'docs/docs/guide/' with remote 'docs/guide/'
28e9d98c3 is described below
commit 28e9d98c398adf168e4c42179ca89e1a675a27db
Author: chaokunyang <[email protected]>
AuthorDate: Mon Dec 22 10:23:33 2025 +0000
🔄 synced local 'docs/docs/guide/' with remote 'docs/guide/'
---
docs/docs/guide/rust/custom-serializers.md | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/docs/docs/guide/rust/custom-serializers.md
b/docs/docs/guide/rust/custom-serializers.md
index 833b20147..a7f403a29 100644
--- a/docs/docs/guide/rust/custom-serializers.md
+++ b/docs/docs/guide/rust/custom-serializers.md
@@ -34,7 +34,7 @@ For types that don't support `#[derive(ForyObject)]`,
implement the `Serializer`
use fory::{Fory, ReadContext, WriteContext, Serializer, ForyDefault, Error};
use std::any::Any;
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Default)]
struct CustomType {
value: i32,
name: String,
@@ -63,6 +63,7 @@ impl Serializer for CustomType {
}
}
+// ForyDefault delegates to Default
impl ForyDefault for CustomType {
fn fory_default() -> Self {
Self::default()
@@ -70,6 +71,11 @@ impl ForyDefault for CustomType {
}
```
+> **Note**: When implementing `ForyDefault` manually, ensure your type also
implements `Default` if you use `Self::default()`.
+> Alternatively, you can construct a default instance directly in
`fory_default()`.
+>
+> **Tip**: If your type supports `#[derive(ForyObject)]`, you can use
`#[fory(generate_default)]` to automatically generate both `ForyDefault` and
`Default` implementations.
+
## Registering Custom Serializers
```rust
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]