From e73d140b51d7bd4b42cadf2dbd825b1dbc7cedb6 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Fri, 13 Nov 2020 17:17:16 +0100 Subject: add suggestion ..Default::default() for remaining struct fields in a constructor #6492 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/assists/src/utils.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'crates/assists/src') 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 { } } +pub mod default { + pub trait Default: Sized { + fn default() -> Self; + } +} + pub mod iter { pub use self::traits::{collect::IntoIterator, iterator::Iterator}; mod traits { @@ -327,7 +333,7 @@ pub mod option { } pub mod prelude { - pub use crate::{convert::From, iter::{IntoIterator, Iterator}, option::Option::{self, *}}; + pub use crate::{convert::From, iter::{IntoIterator, Iterator}, option::Option::{self, *}, default::Default}; } #[prelude_import] pub use prelude::*; @@ -345,6 +351,10 @@ pub use prelude::*; self.find_enum("core:option:Option") } + pub fn core_default_Default(&self) -> Option { + self.find_trait("core:default:Default") + } + pub fn core_iter_Iterator(&self) -> Option { self.find_trait("core:iter:traits:iterator:Iterator") } -- cgit v1.2.3 From 9f15de77f92a4f3bdd76039d5a851e608d244c0f Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Fri, 13 Nov 2020 23:20:26 +0100 Subject: add suggestion ..Default::default() for remaining struct fields in a constructor #6492 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/assists/src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/assists/src') diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs index 3fef75d57..7bd338e99 100644 --- a/crates/assists/src/utils.rs +++ b/crates/assists/src/utils.rs @@ -258,7 +258,7 @@ pub mod convert { } pub mod default { - pub trait Default: Sized { + pub trait Default { fn default() -> Self; } } -- cgit v1.2.3