# Struct update syntax

**URL:** <https://discourse.julialang.org/t/struct-update-syntax/72557>\
**Category:** Internals & Design\
**Tags:** struct\
**Created:** [December 4, 2021, 12:57am UTC](https://discourse.julialang.org/t/struct-update-syntax/72557 "2021-12-04T00:57:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [December 4, 2021, 12:57am UTC](https://discourse.julialang.org/t/struct-update-syntax/72557/1 "2021-12-04T00:57:30Z")

</div>

Rust has a [struct update syntax](https://doc.rust-lang.org/book/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax) that allows you to create a new struct object from another one by changing only some fields. That looks very convenient and would make me want to use more immutable types.

Has there been any discussion about adding such syntax to Julia? Something along the line of:

```julia
struct Point
    x::Int
    y::Int
    z::Int
end

p = Point(1, 2, 3)
q = Point(x = 10, p...) # crazy syntax, just a thought

```

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [December 4, 2021, 1:00am UTC](https://discourse.julialang.org/t/struct-update-syntax/72557/2 "2021-12-04T01:00:04Z")

</div>

Setfield sort of does that:

```julia
using Setfield
q = @set p.x = 1.0

```

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [December 4, 2021, 1:16am UTC](https://discourse.julialang.org/t/struct-update-syntax/72557/3 "2021-12-04T01:16:25Z")

</div>

There is already some similar precedence from named tuples for something like that, right?

```julia
p = (x=1,y=2,z=3)
q = (p..., x=10)

```
