Skip to content

Commit 1454eac

Browse files
authored
Merge pull request #1082 from dtolnay/fromdoc
Improve Value From and FromIterator docs
2 parents a8e6f75 + 0f072fa commit 1454eac

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/value/from.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ from_integer! {
2828
}
2929

3030
impl From<f32> for Value {
31-
/// Convert 32-bit floating point number to `Value`
31+
/// Convert 32-bit floating point number to `Value::Number`, or
32+
/// `Value::Null` if infinite or NaN.
3233
///
3334
/// # Examples
3435
///
@@ -44,7 +45,8 @@ impl From<f32> for Value {
4445
}
4546

4647
impl From<f64> for Value {
47-
/// Convert 64-bit floating point number to `Value`
48+
/// Convert 64-bit floating point number to `Value::Number`, or
49+
/// `Value::Null` if infinite or NaN.
4850
///
4951
/// # Examples
5052
///
@@ -60,7 +62,7 @@ impl From<f64> for Value {
6062
}
6163

6264
impl From<bool> for Value {
63-
/// Convert boolean to `Value`
65+
/// Convert boolean to `Value::Bool`.
6466
///
6567
/// # Examples
6668
///
@@ -76,7 +78,7 @@ impl From<bool> for Value {
7678
}
7779

7880
impl From<String> for Value {
79-
/// Convert `String` to `Value`
81+
/// Convert `String` to `Value::String`.
8082
///
8183
/// # Examples
8284
///
@@ -92,7 +94,7 @@ impl From<String> for Value {
9294
}
9395

9496
impl From<&str> for Value {
95-
/// Convert string slice to `Value`
97+
/// Convert string slice to `Value::String`.
9698
///
9799
/// # Examples
98100
///
@@ -108,7 +110,7 @@ impl From<&str> for Value {
108110
}
109111

110112
impl<'a> From<Cow<'a, str>> for Value {
111-
/// Convert copy-on-write string to `Value`
113+
/// Convert copy-on-write string to `Value::String`.
112114
///
113115
/// # Examples
114116
///
@@ -133,7 +135,7 @@ impl<'a> From<Cow<'a, str>> for Value {
133135
}
134136

135137
impl From<Number> for Value {
136-
/// Convert `Number` to `Value`
138+
/// Convert `Number` to `Value::Number`.
137139
///
138140
/// # Examples
139141
///
@@ -149,7 +151,7 @@ impl From<Number> for Value {
149151
}
150152

151153
impl From<Map<String, Value>> for Value {
152-
/// Convert map (with string keys) to `Value`
154+
/// Convert map (with string keys) to `Value::Object`.
153155
///
154156
/// # Examples
155157
///
@@ -166,7 +168,7 @@ impl From<Map<String, Value>> for Value {
166168
}
167169

168170
impl<T: Into<Value>> From<Vec<T>> for Value {
169-
/// Convert a `Vec` to `Value`
171+
/// Convert a `Vec` to `Value::Array`.
170172
///
171173
/// # Examples
172174
///
@@ -182,7 +184,7 @@ impl<T: Into<Value>> From<Vec<T>> for Value {
182184
}
183185

184186
impl<T: Clone + Into<Value>> From<&[T]> for Value {
185-
/// Convert a slice to `Value`
187+
/// Convert a slice to `Value::Array`.
186188
///
187189
/// # Examples
188190
///
@@ -198,7 +200,7 @@ impl<T: Clone + Into<Value>> From<&[T]> for Value {
198200
}
199201

200202
impl<T: Into<Value>> FromIterator<T> for Value {
201-
/// Convert an iterable type to a `Value`
203+
/// Create a `Value::Array` by collecting an iterator of array elements.
202204
///
203205
/// # Examples
204206
///
@@ -228,7 +230,7 @@ impl<T: Into<Value>> FromIterator<T> for Value {
228230
}
229231

230232
impl<K: Into<String>, V: Into<Value>> FromIterator<(K, V)> for Value {
231-
/// Convert an iterable type to a `Value`
233+
/// Create a `Value::Object` by collecting an iterator of key-value pairs.
232234
///
233235
/// # Examples
234236
///
@@ -248,7 +250,7 @@ impl<K: Into<String>, V: Into<Value>> FromIterator<(K, V)> for Value {
248250
}
249251

250252
impl From<()> for Value {
251-
/// Convert `()` to `Value`
253+
/// Convert `()` to `Value::Null`.
252254
///
253255
/// # Examples
254256
///

0 commit comments

Comments
 (0)