# Range syntax is confusing

**URL:** <https://internals.rust-lang.org/t/range-syntax-is-confusing/10573>\
**Category:** language design\
**Created:** [July 15, 2019, 10:20am UTC](https://internals.rust-lang.org/t/range-syntax-is-confusing/10573 "2019-07-15T10:20:45Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![ExpHP](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/exphp/32/6208_2.png) [@ExpHP](https://internals.rust-lang.org/u/ExpHP)\
**Post date:** [July 19, 2019, 9:18pm UTC](https://internals.rust-lang.org/t/range-syntax-is-confusing/10573/26 "2019-07-19T21:18:03Z")

</div>

> [@anon2808951](#):
>
> Isn't "range patterns don't need move because we say so and hacked it that way into the compiler" just another special case?

I'm honestly not sure what would lead you to that conclusion? Patterns in general do not move the thing they match against unless strictly necessary. (ident patterns, enum patterns that contain an ident pattern that moves something, and probably some other funny edge cases)

Look, you can even partially move out of a struct with a struct pattern:

```rust
struct Struct {
    a: Vec<()>,
    b: Vec<()>,
}

fn main() {
    let x = Struct { a: vec![], b: vec![] };
    match x {
        Struct { a, .. } => {},
    };
    x.b; // still valid; only x.a could have been moved
}

```

Heck, you can even do it from within a `Box`:

```rust
fn main() {
    let x = Box::new(Struct { a: vec![], b: vec![] });
    match *x {
        Struct { a, .. } => {},
    };
    x.b; // still valid; only x.a was moved
}

```

(that's a bit surprising actually!)

---

<div class="post-metadata">

**Author:** ![RustyYato](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/rustyyato/32/13627_2.png) [@RustyYato](https://internals.rust-lang.org/u/RustyYato)\
**Post date:** [July 19, 2019, 9:50pm UTC](https://internals.rust-lang.org/t/range-syntax-is-confusing/10573/27 "2019-07-19T21:50:55Z")

</div>

> [@ExpHP](#):
>
> (that's a bit surprising actually!)

Well, [`Box<T>` is pretty special](https://manishearth.github.io/blog/2017/01/10/rust-tidbits-box-is-special/) 😀

---

<div class="post-metadata">

**Author:** ![notriddle](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/notriddle/32/14082_2.png) [@notriddle](https://internals.rust-lang.org/u/notriddle)\
**Post date:** [August 4, 2019, 3:58pm UTC](https://internals.rust-lang.org/t/range-syntax-is-confusing/10573/28 "2019-08-04T15:58:04Z")

</div>

Split this topic on August 4, 2019, 3:58pm UTC

A post was split to a new topic: [Disabling typographer auto-fixups](https://internals.rust-lang.org/t/disabling-typographer-auto-fixups/10663)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [November 2, 2019, 4:05pm UTC](https://internals.rust-lang.org/t/range-syntax-is-confusing/10573/29 "2019-11-02T16:05:54Z")

</div>

Closed on November 2, 2019, 4:05pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

[Previous page](https://internals.rust-lang.org/t/range-syntax-is-confusing/10573.md?page=1)
