about summary refs log tree commit diff
path: root/src/utils.rs
diff options
context:
space:
mode:
authorNick Cameron <nrc@ncameron.org>2018-04-30 11:06:33 +1200
committerGitHub <noreply@github.com>2018-04-30 11:06:33 +1200
commitdae9fb64b6e9d6acbfe336a0f12689107e05331e (patch)
treef719913befa48d2effb024ac2acde6d814a7e761 /src/utils.rs
parentfb9a5add9b651d64ecf365ade61d83d76fd6b307 (diff)
parent3432807ac2c9118058e61961f1d14bdb709004f5 (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.rs10
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("//"))
 }