当 F# 4.5 was announced ,据说:
The F# feature set is comprised of
[...]
The ability to produce IsByRefLike structs (examples of such structs: Span<'T>and ReadOnlySpan<'T>).
如何“生产”这些类型?我尝试了 [<IsByRefLike>]
属性,但在 .NET Standard 2.0 中找不到。
最佳答案
该属性位于 System.Runtime.CompilerServices
open System.Runtime.CompilerServices
[<Struct; IsByRefLike>]
type Apa =
{ A: Span<int>
B: int }
Phillip Carter 在 What's new in F# 4.5 中谈到了这一点(大约 21 分钟)。
它适用于 .NET Core 和 .NET Framework,但不适用于 .NET Standard 2.0。
关于f# - 如何在 .NET Standard 2.0 的 F# 中定义 ref 结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53936612/