Proper way to get a mutable struct for Memory / Span?

前端 未结 1 1914
面向向阳花
面向向阳花 2021-01-05 19:04

For a network protocol implementation I want to make use of the new Memory and Span classes to achieve zero-copy of the buffer while accessing the

相关标签:
1条回答
  • 2021-01-05 19:40

    Oof. It looks like MemoryMarshal.Cast is what used to be the NonPortableCast extension method (from: this commit), in which case - yes, that's the appropriate way to thunk between layouts of spans, most commonly (but not exclusively) like in this case - between byte and some struct.

    0 讨论(0)
提交回复
热议问题