Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`for` should work on *[N]T #1663

Closed
tgschultz opened this Issue Oct 18, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@tgschultz
Copy link
Contributor

tgschultz commented Oct 18, 2018

Given that a pointer to an array is indexable and has a comptime-known length, it should be able to be used in the same ways as an array or slice. This would mean giving it a .len and making it work in for loops.

Currently attempting to use an *[N]T with for throws these two errors:

error: expected array type, found '*const [N]u8'
error: type '*const [N]u8' has no field 'len'

@andrewrk andrewrk added this to the 0.4.0 milestone Oct 18, 2018

@Hejsil

This comment has been minimized.

Copy link
Member

Hejsil commented Nov 6, 2018

Just a note. .len is already supported on *[N]T

test "" {
    var a: [2]u8 = undefined;
    var b = &a;
    @import("std").debug.assert(b.len == 2);
}

Idk why the for loop gives the error error: type '*const [N]u8' has no field 'len'

thejoshwolfe added a commit that referenced this issue Nov 9, 2018

thejoshwolfe added a commit that referenced this issue Nov 14, 2018

thejoshwolfe added a commit that referenced this issue Nov 15, 2018

Hejsil added a commit that referenced this issue Nov 16, 2018

@andrewrk andrewrk closed this in be9bb0a Nov 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.