Skip to content

Commit afe248a

Browse files
authored
hide import statements from doctests (#2166)
The test runner recently gained the ability to strip hidden lines from extracted test source code just like rustdoc does.[^1] Hiding import lines from doctests makes them easier to read when solving exercises in the web editor. [no important files changed] [^1]: https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#hiding-portions-of-the-example
1 parent 7a701dc commit afe248a

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

exercises/practice/doubly-linked-list/src/pre_implemented.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<T> Cursor<'_, T> {
6161
#[allow(unused)]
6262
#[cfg(feature = "advanced")]
6363
/// ```compile_fail
64-
/// use doubly_linked_list::LinkedList;
64+
/// # use doubly_linked_list::LinkedList;
6565
/// trait AssertSend: Send {}
6666
/// impl<T> AssertSend for LinkedList<T> {}
6767
/// ```
@@ -70,7 +70,7 @@ const _ILLEGAL_SEND: () = ();
7070
#[allow(unused)]
7171
#[cfg(feature = "advanced")]
7272
/// ```compile_fail
73-
/// use doubly_linked_list::LinkedList;
73+
/// # use doubly_linked_list::LinkedList;
7474
/// trait AssertSync: Sync {}
7575
/// impl<T> AssertSync for LinkedList<T> {}
7676
/// ```

exercises/practice/macros/src/compile_fail_tests.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,89 @@
11
// To activate a doctest locally, remove ",ignore" from the code block.
22

33
/// ```compile_fail,ignore
4-
/// use macros::hashmap;
5-
/// use std::collections::HashMap;
4+
/// # use macros::hashmap;
5+
/// # use std::collections::HashMap;
66
///
77
/// // using only commas is invalid
88
/// let _hm: HashMap<_, _> = hashmap!('a', 1);
99
/// ```
1010
const _COMMA_SEPARATOR: () = ();
1111

1212
/// ```compile_fail,ignore
13-
/// use macros::hashmap;
14-
/// use std::collections::HashMap;
13+
/// # use macros::hashmap;
14+
/// # use std::collections::HashMap;
1515
///
1616
/// // a single trailing comma is okay, but two is not
1717
/// let _hm: HashMap<_, _> = hashmap!('a' => 2, ,);
1818
/// ```
1919
const _DOUBLE_TRAILING_COMMAS: () = ();
2020

2121
/// ```compile_fail,ignore
22-
/// use macros::hashmap;
23-
/// use std::collections::HashMap;
22+
/// # use macros::hashmap;
23+
/// # use std::collections::HashMap;
2424
///
2525
/// // a single random comma is not valid
2626
/// let _hm: HashMap<(), ()> = hashmap!(,);
2727
/// ```
2828
const _ONLY_COMMA: () = ();
2929

3030
/// ```compile_fail,ignore
31-
/// use macros::hashmap;
32-
/// use std::collections::HashMap;
31+
/// # use macros::hashmap;
32+
/// # use std::collections::HashMap;
3333
///
3434
/// // a single argument is invalid
3535
/// let _hm: HashMap<_, _> = hashmap!('a');
3636
/// ```
3737
const _SINGLE_ARGUMENT: () = ();
3838

3939
/// ```compile_fail,ignore
40-
/// use macros::hashmap;
41-
/// use std::collections::HashMap;
40+
/// # use macros::hashmap;
41+
/// # use std::collections::HashMap;
4242
///
4343
/// // three arguments are invalid
4444
/// hashmap!('a' => 1, 'b');
4545
/// ```
4646
const _TRIPLE_ARGUMENTS: () = ();
4747

4848
/// ```compile_fail,ignore
49-
/// use macros::hashmap;
50-
/// use std::collections::HashMap;
49+
/// # use macros::hashmap;
50+
/// # use std::collections::HashMap;
5151
///
5252
/// // a single random arrow is not valid
5353
/// let _hm: HashMap<(), ()> = hashmap!(=>);
5454
/// ```
5555
const _ONLY_ARROW: () = ();
5656

5757
/// ```compile_fail,ignore
58-
/// use macros::hashmap;
59-
/// use std::collections::HashMap;
58+
/// # use macros::hashmap;
59+
/// # use std::collections::HashMap;
6060
///
6161
/// // a trailing => isn't valid either
6262
/// hashmap!('a' => 2, =>);
6363
/// ```
6464
const _TRAILING_ARROW: () = ();
6565

6666
/// ```compile_fail,ignore
67-
/// use macros::hashmap;
68-
/// use std::collections::HashMap;
67+
/// # use macros::hashmap;
68+
/// # use std::collections::HashMap;
6969
///
7070
/// // leading commas are not valid
7171
/// let _hm: HashMap<_, _> = hashmap!(, 'a' => 2);
7272
/// ```
7373
const _LEADING_COMMA: () = ();
7474

7575
/// ```compile_fail,ignore
76-
/// use macros::hashmap;
77-
/// use std::collections::HashMap;
76+
/// # use macros::hashmap;
77+
/// # use std::collections::HashMap;
7878
///
7979
/// // Key value pairs must be separated by commas
8080
/// let _hm: HashMap<_, _> = hashmap!('a' => 1 'b' => 2);
8181
/// ```
8282
const _MISSING_COMMA: () = ();
8383

8484
/// ```compile_fail,ignore
85-
/// use macros::hashmap;
86-
/// use std::collections::HashMap;
85+
/// # use macros::hashmap;
86+
/// # use std::collections::HashMap;
8787
///
8888
/// // an argument should come between each pair of commas
8989
/// let _hm: HashMap<_, _> = hashmap!('a' => 1, , 'b' => 2);

0 commit comments

Comments
 (0)