Skip to content

Commit

Permalink
fix panic if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
XAMPPRocky committed Jun 22, 2020
1 parent e6296f6 commit e4ff3c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ impl SliceExt for [u8] {
},
);

if self[start..].is_empty() {
return &[]
}

&self[start..=end]
}

Expand Down
14 changes: 14 additions & 0 deletions tests/data/markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 14 lines 4 code 7 comments 3 blanks
Sit dicta esse doloremque officia iusto? Assumenda alias aperiam id quis
pariatur? Libero modi harum iusto modi magni? Sit temporibus fugit facere
nostrum culpa ipsum totam! Reprehenderit praesentium obcaecati nemo.

```rust
use std::println;

fn main () {
// Comment
println!("Hello World!");
}
```

0 comments on commit e4ff3c2

Please sign in to comment.