1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! PHP function [`var_export()`](https://www.php.net/manual/en/function.var-export) support for [Serde](https://crates.io/crates/serde).
//!
//! ## Installation
//!
//! With [cargo add](https://github.com/killercup/cargo-edit) installed run:
//!
//! ```sh
//! $ cargo add -s serde_var_export
//! ```
//!
//! ## Example
//!
//! ```rust
//! use serde_derive::Serialize;
//!
//! #[derive(Serialize)]
//! struct Foo {
//! names: Vec<String>,
//! nums: Vec<i32>,
//! }
//!
//! fn main() {
//! let foo = Foo {
//! names: vec!["hello".to_owned(), "world".to_owned()],
//! nums: vec![1, 2, 3],
//! };
//! let s = serde_var_export::to_string(&foo).unwrap();
//! println!("{}", s);
//! }
//! ```
//!
//! print result:
//!
//! ```php
//! array(
//! 'names' =>
//! array(
//! 0 => 'hello',
//! 1 => 'world',
//! ),
//! 'nums' =>
//! array(
//! 0 => 1,
//! 1 => 2,
//! 2 => 3,
//! ),
//! )
//! ```
//!
//! ## Limitation
//!
//! Now only support serialization, deserialization will support in future.
//!
//! ## License
//!
//! The Unlicense.
pub use ;
pub use ;