# Simplify constructor function

**URL:** <https://internals.rust-lang.org/t/simplify-constructor-function/20960>\
**Category:** language design\
**Created:** [June 2, 2024, 2:55pm UTC](https://internals.rust-lang.org/t/simplify-constructor-function/20960 "2024-06-02T14:55:40Z")\
**Posts on this page:** 1\
**Showing post:** 36

<div class="post-metadata">

**Author:** ![Yokin](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/yokin/32/12030_2.png) [@Yokin](https://internals.rust-lang.org/u/Yokin)\
**Post date:** [June 10, 2024, 8:13am UTC](https://internals.rust-lang.org/t/simplify-constructor-function/20960/36 "2024-06-10T08:13:17Z")

</div>

I think most would agree that constructor functions don't need special syntax sugar, but some existing ideas just coincidentally resolve the issue raised by the post ([A](https://internals.rust-lang.org/t/pre-rfc-struct-constructor-name-inference/10960), [B](https://github.com/rust-lang/rfcs/pull/3629)).

At the same time there are good reasons to have some kind of bracket elision in general. For example, imagine you have a large code block like:

```rust
match letter {
    Letter::A => println!("A"),
    Letter::B => println!("B"),
    Letter::C => println!("C"),
    // ..
    Letter::X => println!("X"),
    Letter::Y => println!("Y"),
    Letter::Z => println!("Z"),
}

```

and you want to apply a minor control-flow effect to that entire block. You'd have to find both ends of the block, wrap it in brackets, and preferably indent the contents.

It would be much more efficient if you could just prefix the block:

```rust
if can_print => match letter {
    Letter::A => println!("A"),
    Letter::B => println!("B"),
    Letter::C => println!("C"),
    // ..
    Letter::X => println!("X"),
    Letter::Y => println!("Y"),
    Letter::Z => println!("Z"),
}

```

After testing you might realize that this change doesn't work out, or it was just temporary from the start. Either way, reverting the change is just as easy (whereas reverting bracketing and indentation is tedious even with a decent editor in my experience). It's like the difference between function and method calls; there's a reason people use infix notation.

Now, it's arguable whether this conflicts with Rust's goals as a language (maybe it makes code harder to review), but bracket elision is definitely useful for prototyping volatile ideas. I know that I often wanna be able to prototype lots of changes (minor or major) without investing too much effort into each one, while also keeping the code easy to navigate.

---

_[View the full topic](https://internals.rust-lang.org/t/simplify-constructor-function/20960)._
