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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! This library lets you deserialize the output of [`Debug`] into a serde
//! struct.
//!
//! If you would like to do the opposite (output [`Debug`] via [`Serialize`])
//! take a look at [`serde_fmt`](https://docs.rs/serde_fmt).
//!
//! # Getting Started
//! Add `serde_dbgfmt` to your `Cargo.toml`:
//! ```toml
//! [dependencies]
//! ```
//!
//! # Deserializing a struct
//! ```
//! use serde::Deserialize;
//!
//! #[derive(Debug, Deserialize)]
//! struct Test {
//! message: String,
//! }
//!
//! let text = format!("{:?}", Test { message: "Hello, World!".into() });
//! let value: Test = serde_dbgfmt::from_str(&text)
//! .expect("failed to deserialize from the debug repr");
//!
//! assert_eq!(value.message, "Hello, World!");
//! ```
//!
//! # Caveats and Limitations
//! - This library parses the format emitted by the debug helpers in
//! [`std::fmt`]. Custom debug representations will not necessarily use these
//! debug helpers and may not emit output that is compatible with them.
//! - The debug format emitted by the helpers above is not guaranteed to be
//! stable. While it has remained remarkably stable there is no guarantee
//! that it will not be changed in the future.
//! - The names of the structs used to deserialize must match those in the text
//! debug representation. You can use `#[serde(rename = "..")]` if you want to
//! use a different struct name in your codebase.
//!
//! [`Debug`]: std::fmt::Debug
//! [`Serialize`]: serde::Serialize
use Debug;
use DeserializeOwned;
use Deserialize;
pub use crateDeserializer;
pub use crateError;
/// Parse a `T` from the string containing its debug representation.
/// Parse the debug representation of `U` as a `T`.