set[T].len is an alias for set[T].card (#11885) [feature]
This commit is contained in:
parent
61c66abbfe
commit
d208d7a995
2 changed files with 7 additions and 0 deletions
|
|
@ -1111,6 +1111,9 @@ proc card*[T](x: set[T]): int {.magic: "Card", noSideEffect.}
|
|||
## var a = {1, 3, 5, 7}
|
||||
## echo card(a) # => 4
|
||||
|
||||
proc len*[T](x: set[T]): int {.magic: "Card", noSideEffect.}
|
||||
## An alias for `card(x)`.
|
||||
|
||||
proc ord*[T: Ordinal|enum](x: T): int {.magic: "Ord", noSideEffect.}
|
||||
## Returns the internal `int` value of an ordinal value ``x``.
|
||||
##
|
||||
|
|
|
|||
|
|
@ -207,6 +207,10 @@ echo warnUninit in gNotes
|
|||
doAssert {-1.int8, -2, -2}.card == 2
|
||||
doAssert {1, 2, 2, 3..5, 4..6}.card == 6
|
||||
|
||||
# merely test the alias
|
||||
doAssert {-1.int8, -2, -2}.len == 2
|
||||
doAssert {1, 2, 2, 3..5, 4..6}.len == 6
|
||||
|
||||
type Foo = enum
|
||||
Foo1 = 0
|
||||
Foo2 = 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue