diff options
author | Benjamin Coenen <[email protected]> | 2020-11-13 16:17:16 +0000 |
---|---|---|
committer | Benjamin Coenen <[email protected]> | 2020-11-13 16:17:16 +0000 |
commit | e73d140b51d7bd4b42cadf2dbd825b1dbc7cedb6 (patch) | |
tree | 1b7ec0cd16f1df8912a7f26cfdd6e5a6a5f91571 /crates/assists | |
parent | 9beec7c26330f359d773ff472a59f59396e1b5c3 (diff) |
add suggestion ..Default::default() for remaining struct fields in a constructor #6492
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/assists')
-rw-r--r-- | crates/assists/src/utils.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs index 7071fe96b..3fef75d57 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 | ||
260 | pub mod default { | ||
261 | pub trait Default: Sized { | ||
262 | fn default() -> Self; | ||
263 | } | ||
264 | } | ||
265 | |||
260 | pub mod iter { | 266 | pub 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 | ||
329 | pub mod prelude { | 335 | pub 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] |
333 | pub use prelude::*; | 339 | pub 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 | } |