File tree 1 file changed +13
-12
lines changed
1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -352,12 +352,7 @@ impl<T> Grid<T> {
352
352
T : Default ,
353
353
{
354
354
if rows == 0 || cols == 0 {
355
- return Self {
356
- data : Vec :: new ( ) ,
357
- rows : 0 ,
358
- cols : 0 ,
359
- order,
360
- } ;
355
+ return Self :: default ( ) ;
361
356
}
362
357
let mut data = Vec :: new ( ) ;
363
358
data. resize_with ( rows. checked_mul ( cols) . unwrap ( ) , T :: default) ;
@@ -397,12 +392,7 @@ impl<T> Grid<T> {
397
392
T : Clone ,
398
393
{
399
394
if rows == 0 || cols == 0 {
400
- return Self {
401
- data : Vec :: new ( ) ,
402
- rows : 0 ,
403
- cols : 0 ,
404
- order,
405
- } ;
395
+ return Self :: default ( ) ;
406
396
}
407
397
Self {
408
398
data : vec ! [ data; rows. checked_mul( cols) . unwrap( ) ] ,
@@ -1471,6 +1461,17 @@ impl<T> Grid<T> {
1471
1461
}
1472
1462
}
1473
1463
1464
+ impl < T > Default for Grid < T > {
1465
+ fn default ( ) -> Self {
1466
+ Self {
1467
+ data : Vec :: default ( ) ,
1468
+ cols : 0 ,
1469
+ rows : 0 ,
1470
+ order : Order :: default ( ) ,
1471
+ }
1472
+ }
1473
+ }
1474
+
1474
1475
impl < T : Clone > Clone for Grid < T > {
1475
1476
fn clone ( & self ) -> Self {
1476
1477
Grid {
You can’t perform that action at this time.
0 commit comments