5 use std::collections::HashMap;
7 struct FooDefault<'a> {
22 impl std::default::Default for FooDefault<'_> {
23 fn default() -> Self {
29 e: Default::default(),
33 i: [vec![], vec![], vec![]],
41 struct TupleDefault(bool, i32, u64);
43 impl std::default::Default for TupleDefault {
44 fn default() -> Self {
53 impl std::default::Default for FooND1 {
54 fn default() -> Self {
63 impl std::default::Default for FooND2 {
64 fn default() -> Self {
79 impl Default for FooNDNew {
80 fn default() -> Self {
85 struct FooNDVec(Vec<i32>);
87 impl Default for FooNDVec {
88 fn default() -> Self {
93 struct StrDefault<'a>(&'a str);
95 impl Default for StrDefault<'_> {
96 fn default() -> Self {
102 struct AlreadyDerived(i32, bool);
111 fn default() -> Self {
122 fn default() -> Self {
127 struct RustIssue26925<T> {
131 // We should watch out for cases where a manual impl is needed because a
132 // derive adds different type bounds (https://github.com/rust-lang/rust/issues/26925).
133 // For example, a struct with Option<T> does not require T: Default, but a derive adds
134 // that type bound anyways. So until #26925 get fixed we should disable lint
135 // for the following case
136 impl<T> Default for RustIssue26925<T> {
137 fn default() -> Self {
142 struct SpecializedImpl<A, B> {
147 impl<T: Default> Default for SpecializedImpl<T, T> {
148 fn default() -> Self {
156 struct WithoutSelfCurly {
160 impl Default for WithoutSelfCurly {
161 fn default() -> Self {
162 WithoutSelfCurly { a: false }
166 struct WithoutSelfParan(bool);
168 impl Default for WithoutSelfParan {
169 fn default() -> Self {
170 WithoutSelfParan(false)
174 // https://github.com/rust-lang/rust-clippy/issues/7655
176 pub struct SpecializedImpl2<T> {
180 impl Default for SpecializedImpl2<String> {
181 fn default() -> Self {
182 Self { v: Vec::new() }
186 // https://github.com/rust-lang/rust-clippy/issues/7654
195 impl Default for Color {
196 fn default() -> Self {
197 Color { r: 0, g: 0, b: 0 }
207 impl Default for Color2 {
209 fn default() -> Self {
210 Self { r: 0, g: 0, b: 0 }
214 pub struct RepeatDefault1 {
218 impl Default for RepeatDefault1 {
219 fn default() -> Self {
220 RepeatDefault1 { a: [0; 32] }
224 pub struct RepeatDefault2 {
228 impl Default for RepeatDefault2 {
229 fn default() -> Self {
230 RepeatDefault2 { a: [0; 33] }
234 // https://github.com/rust-lang/rust-clippy/issues/7753
236 pub enum IntOrString {
241 impl Default for IntOrString {
242 fn default() -> Self {