Skip to content

Instantly share code, notes, and snippets.

@Tarmil
Created April 26, 2020 17:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tarmil/f65265c2e928dbf184c926ee917a6033 to your computer and use it in GitHub Desktop.
Save Tarmil/f65265c2e928dbf184c926ee917a6033 to your computer and use it in GitHub Desktop.
namespace Avalonia.Media.TextFormatting.Unicode
open Avalonia.Utility
[<Struct; IsByRefLike>]
type CodepointEnumerator =
val mutable text : ReadOnlySlice<char>
val mutable current : Codepoint
new(text) =
{ text = text; current = Codepoint.ReplacementCodepoint }
member this.Current = this.current
member this.MoveNext() =
if this.text.IsEmpty then
this.current <- Codepoint.ReplacementCodepoint
false
else
let current, count = Codepoint.ReadAt(this.text, 0)
this.current <- current
this.text <- this.text.Skip(count)
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment