Skip to content

Commit 708e6a1

Browse files
authored
Fix panic example (#69)
* testing CI * fix some panic examples * another fix --------- Co-authored-by: Luke Videckis <lukevideckis@gmail.com>
1 parent add1a21 commit 708e6a1

File tree

3 files changed

+6
-20
lines changed

3 files changed

+6
-20
lines changed

src/data_structures/binary_trie.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ struct Node {
1111
/// use programming_team_code_rust::data_structures::binary_trie::BinaryTrie;
1212
///
1313
/// let mut trie = BinaryTrie::default();
14+
/// assert!(std::panic::catch_unwind(|| trie.min_xor(4)).is_err());
1415
/// trie.update(1, 1);
16+
/// assert!(std::panic::catch_unwind(|| trie.min_xor(4)).is_ok());
1517
/// trie.update(2, 1);
1618
/// trie.update(3, 1);
1719
/// trie.update(2, -1);
@@ -75,14 +77,6 @@ impl BinaryTrie {
7577

7678
/// Find the minimum xor of `num` and any number in the trie
7779
///
78-
/// # Panics
79-
/// ```panic
80-
/// use programming_team_code_rust::data_structures::binary_trie::BinaryTrie;
81-
///
82-
/// let trie = BinaryTrie::default();
83-
/// trie.min_xor(0);
84-
/// ```
85-
///
8680
/// # Complexity
8781
/// - Time: O(log(max_num))
8882
/// - Space: O(1)

src/graphs/cuts.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@
1818
/// assert_eq!(num_bccs, 2);
1919
/// assert_eq!(is_cut, vec![false, true, false]);
2020
/// assert_eq!(bcc_id, vec![1, 1, 0, 1]);
21-
/// ```
2221
///
23-
/// # Panics
24-
/// ```panic
25-
/// use programming_team_code_rust::graphs::cuts::get_cuts;
26-
/// let mut adj = vec![vec![]; 1];
22+
/// // self edges not allowed
23+
/// adj = vec![vec![]; 1];
2724
/// for (i, &(u, v)) in [(0,0)].iter().enumerate() {
2825
/// adj[u].push((v, i));
2926
/// adj[v].push((u, i));
3027
/// }
31-
/// let (_, _, _) = get_cuts(&adj, 1);
28+
/// assert!(std::panic::catch_unwind(|| get_cuts(&adj, 1)).is_err());
3229
/// ```
3330
///
3431
/// # Complexity

src/strings/manacher.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515
/// use programming_team_code_rust::strings::manacher::manacher;
1616
///
1717
/// assert_eq!(manacher(&"baaba".chars().collect::<Vec<_>>()), vec![0, 1, 1, 0, 2, 3, 2, 4, 4]);
18-
/// ```
19-
///
20-
/// # Panics
21-
/// ```panic
22-
/// use programming_team_code_rust::strings::manacher::manacher;
23-
/// manacher(&"".chars().collect::<Vec<_>>());
18+
/// assert!(std::panic::catch_unwind(|| manacher::<usize>(&[])).is_err());
2419
/// ```
2520
///
2621
/// # Complexity (n = s.len())

0 commit comments

Comments
 (0)