Skip to content

Commit ee8de21

Browse files
committed
docs(gctx): move inline comment to doc comment for Value<T>
1 parent b00cd3d commit ee8de21

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/cargo/util/context/value.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@
77
//! debugging). The `Value<T>` type here can be used to deserialize a `T` value
88
//! from configuration, but also record where it was deserialized from when it
99
//! was read.
10+
//!
11+
//! Deserializing `Value<T>` is pretty special, and serde doesn't have built-in
12+
//! support for this operation. To implement this we extend serde's "data model"
13+
//! a bit. We configure deserialization of `Value<T>` to basically only work with
14+
//! our one deserializer using configuration.
15+
//!
16+
//! We define that `Value<T>` deserialization asks the deserializer for a very
17+
//! special struct name and struct field names. In doing so the deserializer will
18+
//! recognize this and synthesize a magical value for the `definition` field when
19+
//! we deserialize it. This protocol is how we're able to have a channel of
20+
//! information flowing from the configuration deserializer into the
21+
//! deserialization implementation here.
22+
//!
23+
//! You'll want to also check out the implementation of `ValueDeserializer` in
24+
//! `de.rs`. Also note that the names below are intended to be invalid Rust
25+
//! identifiers to avoid how they might conflict with other valid structures.
26+
//! Finally the `definition` field is transmitted as a tuple of i32/string, which
27+
//! is effectively a tagged union of `Definition` itself.
1028
1129
use crate::util::context::GlobalContext;
1230
use serde::de;
@@ -29,24 +47,6 @@ pub struct Value<T> {
2947

3048
pub type OptValue<T> = Option<Value<T>>;
3149

32-
// Deserializing `Value<T>` is pretty special, and serde doesn't have built-in
33-
// support for this operation. To implement this we extend serde's "data model"
34-
// a bit. We configure deserialization of `Value<T>` to basically only work with
35-
// our one deserializer using configuration.
36-
//
37-
// We define that `Value<T>` deserialization asks the deserializer for a very
38-
// special struct name and struct field names. In doing so the deserializer will
39-
// recognize this and synthesize a magical value for the `definition` field when
40-
// we deserialize it. This protocol is how we're able to have a channel of
41-
// information flowing from the configuration deserializer into the
42-
// deserialization implementation here.
43-
//
44-
// You'll want to also check out the implementation of `ValueDeserializer` in
45-
// `de.rs`. Also note that the names below are intended to be invalid Rust
46-
// identifiers to avoid how they might conflict with other valid structures.
47-
// Finally the `definition` field is transmitted as a tuple of i32/string, which
48-
// is effectively a tagged union of `Definition` itself.
49-
5050
pub(crate) const VALUE_FIELD: &str = "$__cargo_private_value";
5151
pub(crate) const DEFINITION_FIELD: &str = "$__cargo_private_definition";
5252
pub(crate) const NAME: &str = "$__cargo_private_Value";

0 commit comments

Comments
 (0)