From 6ac9c4ad6ae2ce246a8c70d468ae2dabb484a03d Mon Sep 17 00:00:00 2001
From: Aleksey Kladov <aleksey.kladov@gmail.com>
Date: Fri, 7 Feb 2020 15:04:50 +0100
Subject: Cleanup

---
 crates/ra_assists/src/assist_ctx.rs | 7 +++----
 crates/ra_assists/src/lib.rs        | 8 ++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

(limited to 'crates/ra_assists/src')

diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs
index b2381bd97..44d6f6808 100644
--- a/crates/ra_assists/src/assist_ctx.rs
+++ b/crates/ra_assists/src/assist_ctx.rs
@@ -57,7 +57,7 @@ pub(crate) struct AssistCtx<'a> {
     should_compute_edit: bool,
 }
 
-impl<'a> Clone for AssistCtx<'a> {
+impl Clone for AssistCtx<'_> {
     fn clone(&self) -> Self {
         AssistCtx {
             db: self.db,
@@ -80,8 +80,7 @@ impl<'a> AssistCtx<'a> {
         label: impl Into<String>,
         f: impl FnOnce(&mut ActionBuilder),
     ) -> Option<Assist> {
-        let label = AssistLabel { label: label.into(), id };
-        assert!(label.label.chars().nth(0).unwrap().is_uppercase());
+        let label = AssistLabel::new(label.into(), id);
 
         let assist = if self.should_compute_edit {
             let action = {
@@ -103,7 +102,7 @@ impl<'a> AssistCtx<'a> {
         label: impl Into<String>,
         f: impl FnOnce() -> Vec<ActionBuilder>,
     ) -> Option<Assist> {
-        let label = AssistLabel { label: label.into(), id };
+        let label = AssistLabel::new(label.into(), id);
         let assist = if self.should_compute_edit {
             let actions = f();
             assert!(!actions.is_empty(), "Assist cannot have no");
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index b71df7e5d..d476088a2 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -34,6 +34,14 @@ pub struct AssistLabel {
     pub id: AssistId,
 }
 
+impl AssistLabel {
+    pub(crate) fn new(label: String, id: AssistId) -> AssistLabel {
+        // FIXME: make fields private, so that this invariant can't be broken
+        assert!(label.chars().nth(0).unwrap().is_uppercase());
+        AssistLabel { label: label.into(), id }
+    }
+}
+
 #[derive(Debug, Clone)]
 pub struct AssistAction {
     pub label: Option<String>,
-- 
cgit v1.2.3