Skip to content
Discussion options

You must be logged in to vote

Honestly the only answer here should be to just cast it to a Span<T> and then get the Length. It jumps through a few hoops but at least the runtime seems perfectly capable of folding everything and just returning the constant value.

Everything else feels unnecessarily complicated to me. Extensions are not a good solution because it's not possible to write a single extension that can cover all inline array types. Source generators can technically get the job done, but they feel seriously overkill too. Given that the compiler knows at all times how long the inline array type is, it feels a little silly that it's not more trivial to just have the compiler emit a Length const or the like on t…

Replies: 4 comments 18 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
12 replies
@CyrusNajmabadi
Comment options

@masonwheeler
Comment options

@TahirAhmadov
Comment options

@masonwheeler
Comment options

@CyrusNajmabadi
Comment options

Comment options

You must be logged in to vote
6 replies
@TahirAhmadov
Comment options

@colejohnson66
Comment options

@TahirAhmadov
Comment options

@masonwheeler
Comment options

@TahirAhmadov
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by CyrusNajmabadi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants