aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/utils.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-11-13 23:30:13 +0000
committerGitHub <[email protected]>2020-11-13 23:30:13 +0000
commite8c803937ce23a6cf74583ad03f9868869c7eea1 (patch)
treefbe7b9be9566169d168c50d035790d3028e3bbe9 /crates/assists/src/utils.rs
parentd1ea9d12fa95d8f8915b44b7a993591fd528d2ba (diff)
parent9f15de77f92a4f3bdd76039d5a851e608d244c0f (diff)
Merge #6544
6544: add suggestion ..Default::default() for remaining struct fields in a constructor r=bnjjj a=bnjjj I'm not sure I should import `assists` crate inside `completions`, maybe we should move out `FamousDefs` from `assists` ? Let me know :) close #6492 Signed-off-by: Benjamin Coenen <[email protected]> Co-authored-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/assists/src/utils.rs')
-rw-r--r--crates/assists/src/utils.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs
index 7071fe96b..7bd338e99 100644
--- a/crates/assists/src/utils.rs
+++ b/crates/assists/src/utils.rs
@@ -257,6 +257,12 @@ pub mod convert {
257 } 257 }
258} 258}
259 259
260pub mod default {
261 pub trait Default {
262 fn default() -> Self;
263 }
264}
265
260pub mod iter { 266pub mod iter {
261 pub use self::traits::{collect::IntoIterator, iterator::Iterator}; 267 pub use self::traits::{collect::IntoIterator, iterator::Iterator};
262 mod traits { 268 mod traits {
@@ -327,7 +333,7 @@ pub mod option {
327} 333}
328 334
329pub mod prelude { 335pub mod prelude {
330 pub use crate::{convert::From, iter::{IntoIterator, Iterator}, option::Option::{self, *}}; 336 pub use crate::{convert::From, iter::{IntoIterator, Iterator}, option::Option::{self, *}, default::Default};
331} 337}
332#[prelude_import] 338#[prelude_import]
333pub use prelude::*; 339pub use prelude::*;
@@ -345,6 +351,10 @@ pub use prelude::*;
345 self.find_enum("core:option:Option") 351 self.find_enum("core:option:Option")
346 } 352 }
347 353
354 pub fn core_default_Default(&self) -> Option<Trait> {
355 self.find_trait("core:default:Default")
356 }
357
348 pub fn core_iter_Iterator(&self) -> Option<Trait> { 358 pub fn core_iter_Iterator(&self) -> Option<Trait> {
349 self.find_trait("core:iter:traits:iterator:Iterator") 359 self.find_trait("core:iter:traits:iterator:Iterator")
350 } 360 }