# Allow a trailing \`..\` in a struct literal, meaning \`.. Default::default()\`

**URL:** <https://internals.rust-lang.org/t/allow-a-trailing-in-a-struct-literal-meaning-default-default/885>\
**Category:** ideas (deprecated)\
**Created:** [November 11, 2014, 11:58pm UTC](https://internals.rust-lang.org/t/allow-a-trailing-in-a-struct-literal-meaning-default-default/885 "2014-11-11T23:58:46Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![abonander](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/abonander/32/1284_2.png) [@abonander](https://internals.rust-lang.org/u/abonander)\
**Post date:** [November 14, 2014, 11:11pm UTC](https://internals.rust-lang.org/t/allow-a-trailing-in-a-struct-literal-meaning-default-default/885/4 "2014-11-14T23:11:07Z")

</div>

This actually already works with functional record update syntax:

```
use std::default::Default;

#[deriving(Default)]
struct Struct;

fn main() {

    let my_struct = Struct { .. Default::default() };
    
}

```

So it’d basically be sugar for that pattern. A function `default()` in the prelude that called `Default::default()` would be super useful, as it’d save an import and some noise. Optimally, the sugar should work with structs that don’t implement `Default`, and instead should look at the omitted fields for implementation, throwing a compiler error if there’s a field that doesn’t have it.

On a related note, it would be awesome if unit structs automatically implemented `Default` since there’s no other state they could possibly be initialized with. Then with this syntax, it would be a lot cleaner:

```
use std::kinds::marker::NoCopy, NoSend, NoSync;

struct Struct {
    nocopy: NoCopy,
    nosend: NoSend,
    nosync: NoSync,
}

let mystruct = Struct { 
    nocopy: NoCopy, // Is this really necessary?
    nosend: NoSend,
    nosync: NoSync,
};

// versus

let mystruct = Struct { .. };

// or

let mystruct = Struct { .. default() };
```

---

_[View the full topic](https://internals.rust-lang.org/t/allow-a-trailing-in-a-struct-literal-meaning-default-default/885)._
