Skip to content

Map methods on constant sized arrays return dynamically sized arrays. #6562

Closed
@mstewartgallus

Description

@mstewartgallus

Consider the following code samples:
(1)

    let mut positions = [Zero::zero (), ..ObjectAmount];
    for uint::range (0, positions.len ()) |ii| {
         positions[ii] = do objects[ii].position
    }

(2)

   let positions = do objects.map |object| { object.position }

Code example number (2) looks much prettier than code example (1) but is incorrect, as it returns a dynamically sized array. The code returns a dynamically sized array because the objects array is coerced to a dynamically sized array, and then the map method is called on the dynamic array. Can some method of making code sample number (2) happen be implemented? Right now, the behaviour is unintuitive, and annoying.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions