aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assist_config.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-05-19 19:29:46 +0100
committerGitHub <[email protected]>2020-05-19 19:29:46 +0100
commit1bc1f28bc58b2dbcf8f8f548c277e2c90e3075cd (patch)
tree7d059b65919b1b64196cc3fc6830eeb99f2f9af0 /crates/ra_assists/src/assist_config.rs
parent131849f2abd94dc8143f0c5d65e022136f29561a (diff)
parent3e9bf7ebabdaa8e9a2972af2dd8e8089a3a0341e (diff)
Merge #4494
4494: Support snippet text edit r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/assist_config.rs')
-rw-r--r--crates/ra_assists/src/assist_config.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/crates/ra_assists/src/assist_config.rs b/crates/ra_assists/src/assist_config.rs
new file mode 100644
index 000000000..c0a0226fb
--- /dev/null
+++ b/crates/ra_assists/src/assist_config.rs
@@ -0,0 +1,27 @@
1//! Settings for tweaking assists.
2//!
3//! The fun thing here is `SnippetCap` -- this type can only be created in this
4//! module, and we use to statically check that we only produce snippet
5//! assists if we are allowed to.
6
7#[derive(Clone, Debug, PartialEq, Eq)]
8pub struct AssistConfig {
9 pub snippet_cap: Option<SnippetCap>,
10}
11
12impl AssistConfig {
13 pub fn allow_snippets(&mut self, yes: bool) {
14 self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None }
15 }
16}
17
18#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19pub struct SnippetCap {
20 _private: (),
21}
22
23impl Default for AssistConfig {
24 fn default() -> Self {
25 AssistConfig { snippet_cap: Some(SnippetCap { _private: () }) }
26 }
27}