File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -33,13 +33,13 @@ def nameOrdinalPairs[E: EnumMirror]: Map[String, Int] =
33
33
def safeLookup [E : EnumMirror ](name : String ): Option [E ] =
34
34
EnumMirror [E ].valueOf(name)
35
35
def safeLookup [E : EnumMirror ](ordinal : Int ): Option [E ] =
36
- EnumMirror [E ].fromOrdinal(name )
36
+ EnumMirror [E ].fromOrdinal(ordinal )
37
37
38
38
// assert that name/ordinal exists for convenience
39
39
def unsafeLookup [E : EnumMirror ](name : String ): E =
40
- EnumMirror [E ].unsafeValueOf (name)
40
+ EnumMirror [E ].valueOfUnsafe (name)
41
41
def unsafeLookup [E : EnumMirror ](ordinal : Int ): E =
42
- EnumMirror [E ].unsafeFromOrdinal(name )
42
+ EnumMirror [E ].fromOrdinalUnsafe(ordinal )
43
43
```
44
44
45
45
` given ` instances of ` EnumMirror ` are not provided automatically, you must explicitly opt in as follows:
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ Type classes are provided in the `enumextensions` package.
15
15
16
16
See the above use cases in action below:
17
17
18
- ``` scala sc:nocompile
18
+ ``` scala
19
19
import enumextensions .EnumMirror
20
20
21
21
def enumName [E : EnumMirror ]: String =
@@ -33,13 +33,13 @@ def nameOrdinalPairs[E: EnumMirror]: Map[String, Int] =
33
33
def safeLookup [E : EnumMirror ](name : String ): Option [E ] =
34
34
EnumMirror [E ].valueOf(name)
35
35
def safeLookup [E : EnumMirror ](ordinal : Int ): Option [E ] =
36
- EnumMirror [E ].fromOrdinal(name )
36
+ EnumMirror [E ].fromOrdinal(ordinal )
37
37
38
38
// assert that name/ordinal exists for convenience
39
39
def unsafeLookup [E : EnumMirror ](name : String ): E =
40
- EnumMirror [E ].unsafeValueOf (name)
40
+ EnumMirror [E ].valueOfUnsafe (name)
41
41
def unsafeLookup [E : EnumMirror ](ordinal : Int ): E =
42
- EnumMirror [E ].unsafeFromOrdinal(name )
42
+ EnumMirror [E ].fromOrdinalUnsafe(ordinal )
43
43
```
44
44
45
45
` given ` instances of ` EnumMirror ` are not provided automatically, you must explicitly opt in as follows:
Original file line number Diff line number Diff line change 3
3
//> using test .dep org.scalameta::munit:1.0.0-M10
4
4
//> using option -Xcheck-macros
5
5
//> using options -siteroot ${.}
6
+ //> using options -project enum-extensions
You can’t perform that action at this time.
0 commit comments