diff options
| author | Nick Cameron <nrc@ncameron.org> | 2018-04-30 11:06:33 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-30 11:06:33 +1200 |
| commit | dae9fb64b6e9d6acbfe336a0f12689107e05331e (patch) | |
| tree | f719913befa48d2effb024ac2acde6d814a7e761 /src/utils.rs | |
| parent | fb9a5add9b651d64ecf365ade61d83d76fd6b307 (diff) | |
| parent | 3432807ac2c9118058e61961f1d14bdb709004f5 (diff) | |
Merge pull request #2656 from topecongiro/issue-2594
Use consistent formatting for empty enum and struct
Diffstat (limited to 'src/utils.rs')
| -rw-r--r-- | src/utils.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs index 115aee7dd2b..e27180de12a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -135,6 +135,16 @@ pub fn outer_attributes(attrs: &[ast::Attribute]) -> Vec<ast::Attribute> { } #[inline] +pub fn is_single_line(s: &str) -> bool { + s.chars().find(|&c| c == '\n').is_none() +} + +#[inline] +pub fn first_line_contains_single_line_comment(s: &str) -> bool { + s.lines().next().map_or(false, |l| l.contains("//")) +} + +#[inline] pub fn last_line_contains_single_line_comment(s: &str) -> bool { s.lines().last().map_or(false, |l| l.contains("//")) } |
