Skip to content

Commit

Permalink
Merge pull request #1091 from kerams/fff
Browse files Browse the repository at this point in the history
Refactor EnumerationMode
  • Loading branch information
edgarfgp authored Dec 15, 2024
2 parents 33ad120 + e4b669e commit 34c6b1b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Fabulous/WidgetDiff.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ type ScalarAttributeComparison =

[<Struct; IsByRefLike; RequireQualifiedAccess; NoComparison; NoEquality>]
type EnumerationMode<'a> =
| AllAddedOrRemoved of struct ('a[] * bool)
| AllAddedOrRemoved of prev: 'a[] * bool // the first element is either prev or next depending on the bool, but using prev as the label allows the compiler to reuse struct fields between cases

Check failure on line 14 in src/Fabulous/WidgetDiff.fs

View workflow job for this annotation

GitHub Actions / build

If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.

Check failure on line 14 in src/Fabulous/WidgetDiff.fs

View workflow job for this annotation

GitHub Actions / build

If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.

Check failure on line 14 in src/Fabulous/WidgetDiff.fs

View workflow job for this annotation

GitHub Actions / build

If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.

Check failure on line 14 in src/Fabulous/WidgetDiff.fs

View workflow job for this annotation

GitHub Actions / build

If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.
| Empty
| ActualDiff of prevNext: struct ('a[] * 'a[])
| ActualDiff of prev: 'a[] * next: 'a[]

Check failure on line 16 in src/Fabulous/WidgetDiff.fs

View workflow job for this annotation

GitHub Actions / build

If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.

Check failure on line 16 in src/Fabulous/WidgetDiff.fs

View workflow job for this annotation

GitHub Actions / build

If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.

Check failure on line 16 in src/Fabulous/WidgetDiff.fs

View workflow job for this annotation

GitHub Actions / build

If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.

Check failure on line 16 in src/Fabulous/WidgetDiff.fs

View workflow job for this annotation

GitHub Actions / build

If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.

module EnumerationMode =
let fromOptions prev next =
Expand Down Expand Up @@ -314,7 +314,7 @@ and [<Struct; IsByRefLike>] WidgetChangesEnumerator
member e.MoveNext() =
match mode with
| EnumerationMode.Empty -> false
| EnumerationMode.AllAddedOrRemoved(struct (values, added)) ->
| EnumerationMode.AllAddedOrRemoved(values, added) ->
// use prevIndex regardless if it is for adding or removal
let i = e.prevIndex

Expand All @@ -331,7 +331,7 @@ and [<Struct; IsByRefLike>] WidgetChangesEnumerator
else
false

| EnumerationMode.ActualDiff(struct (prev, next)) ->
| EnumerationMode.ActualDiff(prev, next) ->
let mutable prevIndex = e.prevIndex
let mutable nextIndex = e.nextIndex

Expand Down Expand Up @@ -431,7 +431,7 @@ and [<Struct; IsByRefLike>] WidgetCollectionChangesEnumerator
member e.MoveNext() =
match mode with
| EnumerationMode.Empty -> false
| EnumerationMode.AllAddedOrRemoved(struct (values, added)) ->
| EnumerationMode.AllAddedOrRemoved(values, added) ->
// use prevIndex regardless if it is for adding or removal
let i = e.prevIndex

Expand All @@ -448,7 +448,7 @@ and [<Struct; IsByRefLike>] WidgetCollectionChangesEnumerator
else
false

| EnumerationMode.ActualDiff(struct (prev, next)) ->
| EnumerationMode.ActualDiff(prev, next) ->
let mutable prevIndex = e.prevIndex
let mutable nextIndex = e.nextIndex

Expand Down

0 comments on commit 34c6b1b

Please sign in to comment.