Skip to content

Commit be6bbea

Browse files
committed
add documentation for serde module
1 parent b85b188 commit be6bbea

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/lib.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,21 @@
3838
use std::fmt::{self, Debug, Display, Formatter};
3939
use std::num::NonZeroUsize;
4040

41-
#[cfg(feature = "serde")]
4241
/// Implement serde traits for Tree
42+
///
43+
/// ```
44+
/// use ego_tree::{tree, Tree};
45+
///
46+
/// let tree = tree!("a" => {"b", "c" => {"d", "e"}, "f"});
47+
/// let repr = serde_json::to_string(&tree).unwrap();
48+
/// let re_tree: Tree<&str> = serde_json::from_str(&repr).unwrap();
49+
/// ```
50+
///
51+
///
52+
/// # Warning
53+
/// Serialize and Deserialize implementations are recursive. They require an amount of stack memory
54+
/// propotional to the tree depth.
55+
#[cfg(feature = "serde")]
4356
pub mod serde;
4457

4558
/// Vec-backed ID-tree.

0 commit comments

Comments
 (0)