about summary refs log tree commit diff
path: root/src/utils.rs
diff options
context:
space:
mode:
authortopecongiro <seuchida@gmail.com>2018-04-28 13:59:03 +0900
committertopecongiro <seuchida@gmail.com>2018-04-28 13:59:03 +0900
commit82d8dd2f4bdcd61b08c6952e4e6ebdf4db70b299 (patch)
treefb56c706c13c369fbf447977802ffef15207caec /src/utils.rs
parenta9553654592fa9508c4a42b9c47a04fc3b4357d8 (diff)
Factor out a formatting routine for empty struct and tuple
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 2493c9a5c74..9ed1df35a42 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -134,6 +134,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("//"))
 }