Skip to content

Commit 0dff1e9

Browse files
committed
Clean up some rustdoc example code
1 parent d9b7da9 commit 0dff1e9

File tree

4 files changed

+136
-55
lines changed

4 files changed

+136
-55
lines changed

json/src/de.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ impl<'de, 'a, R: Read<'de>> de::Deserializer<'de> for &'a mut Deserializer<R> {
695695
///
696696
/// You can use this to parse JSON strings containing invalid UTF-8 bytes.
697697
///
698-
/// ```
698+
/// ```rust
699699
/// extern crate serde_json;
700700
/// extern crate serde_bytes;
701701
///
@@ -721,7 +721,7 @@ impl<'de, 'a, R: Read<'de>> de::Deserializer<'de> for &'a mut Deserializer<R> {
721721
/// to be valid, and `\u` escape sequences are required to represent valid
722722
/// Unicode code points.
723723
///
724-
/// ```
724+
/// ```rust
725725
/// extern crate serde_json;
726726
/// extern crate serde_bytes;
727727
///

json/src/macros.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/// Construct a `serde_json::Value` from a JSON literal.
22
///
33
/// ```rust
4-
/// # #![allow(unused_variables)]
5-
/// # #[macro_use] extern crate serde_json;
4+
/// # #[macro_use]
5+
/// # extern crate serde_json;
6+
/// #
67
/// # fn main() {
78
/// let value = json!({
89
/// "code": 200,
@@ -25,8 +26,9 @@
2526
/// map with non-string keys, the `json!` macro will panic.
2627
///
2728
/// ```rust
28-
/// # #![allow(unused_variables)]
29-
/// # #[macro_use] extern crate serde_json;
29+
/// # #[macro_use]
30+
/// # extern crate serde_json;
31+
/// #
3032
/// # fn main() {
3133
/// let code = 200;
3234
/// let features = vec!["serde", "json"];
@@ -44,8 +46,9 @@
4446
/// Trailing commas are allowed inside both arrays and objects.
4547
///
4648
/// ```rust
47-
/// # #![allow(unused_variables)]
48-
/// # #[macro_use] extern crate serde_json;
49+
/// # #[macro_use]
50+
/// # extern crate serde_json;
51+
/// #
4952
/// # fn main() {
5053
/// let value = json!([
5154
/// "notice",

json/src/map.rs

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ impl PartialEq for Map<String, Value> {
218218
///
219219
/// ```rust
220220
/// # use serde_json::Value;
221+
/// #
221222
/// # let val = &Value::String("".to_owned());
222223
/// # let _ =
223224
/// match *val {
@@ -243,10 +244,13 @@ impl<'a, Q: ?Sized> ops::Index<&'a Q> for Map<String, Value>
243244
/// present in the map.
244245
///
245246
/// ```rust
246-
/// # #[macro_use] extern crate serde_json;
247+
/// # #[macro_use]
248+
/// # extern crate serde_json;
249+
/// #
247250
/// # fn main() {
248-
/// # let mut map = serde_json::Map::new();
249-
/// # map.insert("key".to_owned(), serde_json::Value::Null);
251+
/// # let mut map = serde_json::Map::new();
252+
/// # map.insert("key".to_owned(), serde_json::Value::Null);
253+
/// #
250254
/// map["key"] = json!("value");
251255
/// # }
252256
/// ```
@@ -424,7 +428,9 @@ impl<'a> Entry<'a> {
424428
/// # Examples
425429
///
426430
/// ```rust
427-
/// # #[macro_use] extern crate serde_json;
431+
/// # #[macro_use]
432+
/// # extern crate serde_json;
433+
/// #
428434
/// # fn main() {
429435
/// let mut map = serde_json::Map::new();
430436
/// map.entry("serde").or_insert(json!(12));
@@ -446,7 +452,9 @@ impl<'a> Entry<'a> {
446452
/// # Examples
447453
///
448454
/// ```rust
449-
/// # #[macro_use] extern crate serde_json;
455+
/// # #[macro_use]
456+
/// # extern crate serde_json;
457+
/// #
450458
/// # fn main() {
451459
/// let mut map = serde_json::Map::new();
452460
/// map.entry("serde").or_insert_with(|| json!("hoho"));
@@ -493,7 +501,9 @@ impl<'a> VacantEntry<'a> {
493501
/// # Examples
494502
///
495503
/// ```rust
496-
/// # #[macro_use] extern crate serde_json;
504+
/// # #[macro_use]
505+
/// # extern crate serde_json;
506+
/// #
497507
/// # fn main() {
498508
/// use serde_json::map::Entry;
499509
///
@@ -519,7 +529,9 @@ impl<'a> OccupiedEntry<'a> {
519529
/// # Examples
520530
///
521531
/// ```rust
522-
/// # #[macro_use] extern crate serde_json;
532+
/// # #[macro_use]
533+
/// # extern crate serde_json;
534+
/// #
523535
/// # fn main() {
524536
/// use serde_json::map::Entry;
525537
///
@@ -544,7 +556,9 @@ impl<'a> OccupiedEntry<'a> {
544556
/// # Examples
545557
///
546558
/// ```rust
547-
/// # #[macro_use] extern crate serde_json;
559+
/// # #[macro_use]
560+
/// # extern crate serde_json;
561+
/// #
548562
/// # fn main() {
549563
/// use serde_json::map::Entry;
550564
///
@@ -569,7 +583,9 @@ impl<'a> OccupiedEntry<'a> {
569583
/// # Examples
570584
///
571585
/// ```rust
572-
/// # #[macro_use] extern crate serde_json;
586+
/// # #[macro_use]
587+
/// # extern crate serde_json;
588+
/// #
573589
/// # fn main() {
574590
/// use serde_json::map::Entry;
575591
///
@@ -596,7 +612,9 @@ impl<'a> OccupiedEntry<'a> {
596612
/// # Examples
597613
///
598614
/// ```rust
599-
/// # #[macro_use] extern crate serde_json;
615+
/// # #[macro_use]
616+
/// # extern crate serde_json;
617+
/// #
600618
/// # fn main() {
601619
/// use serde_json::map::Entry;
602620
///
@@ -624,7 +642,9 @@ impl<'a> OccupiedEntry<'a> {
624642
/// # Examples
625643
///
626644
/// ```rust
627-
/// # #[macro_use] extern crate serde_json;
645+
/// # #[macro_use]
646+
/// # extern crate serde_json;
647+
/// #
628648
/// # fn main() {
629649
/// use serde_json::map::Entry;
630650
///
@@ -650,7 +670,9 @@ impl<'a> OccupiedEntry<'a> {
650670
/// # Examples
651671
///
652672
/// ```rust
653-
/// # #[macro_use] extern crate serde_json;
673+
/// # #[macro_use]
674+
/// # extern crate serde_json;
675+
/// #
654676
/// # fn main() {
655677
/// use serde_json::map::Entry;
656678
///

0 commit comments

Comments
 (0)