Skip to content

Can't borrow array access operator #2684

Open
@Nycto

Description

I expect to be able to borrow the [] function for a distinct seq, but it appears not to be implemented. Either by doing this:

type MySeq* {.borrow: `[]`.} [T] = distinct seq[T]
let points = MySeq(@[ (x: 1, y: 2), (x: 5, y: 6) ])
echo points[0]

Or this:

type MySeq* {.borrow: `[]`.} [T] = distinct seq[T]
proc `[]`*[T](a: MySeq[T], x: int): T {.borrow.}
echo points[0]

Neither of those compile, though.

(See also this forum thread)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions