]> git.lizzy.rs Git - rust.git/blob - crates/ra_assists/src/assist_config.rs
Centralize fixture parsing for assists
[rust.git] / crates / ra_assists / src / assist_config.rs
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)]
8 pub struct AssistConfig {
9     pub snippet_cap: Option<SnippetCap>,
10 }
11
12 impl 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)]
19 pub struct SnippetCap {
20     _private: (),
21 }
22
23 impl Default for AssistConfig {
24     fn default() -> Self {
25         AssistConfig { snippet_cap: Some(SnippetCap { _private: () }) }
26     }
27 }