Skip to content

Commit 6ac9c4a

Browse files
committed
Cleanup
1 parent 2d95047 commit 6ac9c4a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

crates/ra_assists/src/assist_ctx.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub(crate) struct AssistCtx<'a> {
5757
should_compute_edit: bool,
5858
}
5959

60-
impl<'a> Clone for AssistCtx<'a> {
60+
impl Clone for AssistCtx<'_> {
6161
fn clone(&self) -> Self {
6262
AssistCtx {
6363
db: self.db,
@@ -80,8 +80,7 @@ impl<'a> AssistCtx<'a> {
8080
label: impl Into<String>,
8181
f: impl FnOnce(&mut ActionBuilder),
8282
) -> Option<Assist> {
83-
let label = AssistLabel { label: label.into(), id };
84-
assert!(label.label.chars().nth(0).unwrap().is_uppercase());
83+
let label = AssistLabel::new(label.into(), id);
8584

8685
let assist = if self.should_compute_edit {
8786
let action = {
@@ -103,7 +102,7 @@ impl<'a> AssistCtx<'a> {
103102
label: impl Into<String>,
104103
f: impl FnOnce() -> Vec<ActionBuilder>,
105104
) -> Option<Assist> {
106-
let label = AssistLabel { label: label.into(), id };
105+
let label = AssistLabel::new(label.into(), id);
107106
let assist = if self.should_compute_edit {
108107
let actions = f();
109108
assert!(!actions.is_empty(), "Assist cannot have no");

crates/ra_assists/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ pub struct AssistLabel {
3434
pub id: AssistId,
3535
}
3636

37+
impl AssistLabel {
38+
pub(crate) fn new(label: String, id: AssistId) -> AssistLabel {
39+
// FIXME: make fields private, so that this invariant can't be broken
40+
assert!(label.chars().nth(0).unwrap().is_uppercase());
41+
AssistLabel { label: label.into(), id }
42+
}
43+
}
44+
3745
#[derive(Debug, Clone)]
3846
pub struct AssistAction {
3947
pub label: Option<String>,

0 commit comments

Comments
 (0)