Skip to content

Commit 54666ad

Browse files
committed
docs(write): Add guidance
1 parent 13cf518 commit 54666ad

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

crates/toml_write/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
//! A low-level interface for writing out TOML
22
//!
3+
//! Considerations when serializing arbitrary data:
4+
//! - Verify the implementation with [`toml-test-harness`](https://docs.rs/toml-test-harness)
5+
//! - Be sure to group keys under a table before writing another table
6+
//! - Watch for extra trailing newlines and leading newlines, both when starting with top-level
7+
//! keys or a table
8+
//! - When serializing an array-of-tables, be sure to verify that all elements of the array
9+
//! serialize as tables
10+
//! - Standard tables and inline tables may need separate implementations of corner cases,
11+
//! requiring verifying them both
12+
//!
13+
//! When serializing Rust data structures
14+
//! - `Option`: Skip key-value pairs with a value of `None`, otherwise error when seeing `None`
15+
//! - When skipping key-value pairs, be careful that a deeply nested `None` doesn't get skipped
16+
//! - Scalars and arrays are unsupported as top-level data types
17+
//! - Tuples and tuple variants seriallize as arrays
18+
//! - Structs, struct variants, and maps serialize as tables
19+
//! - Newtype variants serialize as to the inner type
20+
//! - Unit variants serialize to a string
21+
//! - Unit and unit structs don't have a clear meaning in TOML
22+
//!
323
//! # Example
424
//!
525
//! ```rust

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy