# \[Idea\] \`.func(args...)\` as a sugar of constructor \`InferredType::func(args...)\`

**URL:** <https://internals.rust-lang.org/t/idea-func-args-as-a-sugar-of-constructor-inferredtype-func-args/17501>\
**Category:** language design\
**Created:** [October 6, 2022, 11:15am UTC](https://internals.rust-lang.org/t/idea-func-args-as-a-sugar-of-constructor-inferredtype-func-args/17501 "2022-10-06T11:15:25Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![scottmcm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scottmcm/32/2355_2.png) [@scottmcm](https://internals.rust-lang.org/u/scottmcm)\
**Post date:** [October 9, 2022, 8:58pm UTC](https://internals.rust-lang.org/t/idea-func-args-as-a-sugar-of-constructor-inferredtype-func-args/17501/15 "2022-10-09T20:58:56Z")

</div>

> [@CAD97](#):
>
> The type must be concretized by context before any methods are called.

I actually started writing a post saying this, but I think this error is somewhat artificial.

Notably, [this works](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f12229c23ddf55619946006847729626) on stable:

```rust
let x: Vec<u32> = {
    let mut x = Default::default();
    if false {
        x
    } else {
        x.push(0);
        x
    }
};
dbg!(x);

```

Which says to me that the inherent method restriction might just be an implementation artifact, not something foundational, and thus that a rewrite of inference might start to enable it.

After all, making the code _less_ specific [makes it compile](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=af381b0b44e0b49641c1e64e1835a5b9):

```rust
let x: Vec<u32> = {
    let mut x = Default::default();
    Extend::extend(&mut x, [0]);
    x
};
dbg!(x);

```

So that also makes it seem non-obvious that inherent methods _need_ to block type inference that way.

---

_[View the full topic](https://internals.rust-lang.org/t/idea-func-args-as-a-sugar-of-constructor-inferredtype-func-args/17501)._
