mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
doc: document [flag] enum attribute (#11282)
This commit is contained in:
parent
76205cff2b
commit
47278b4a7d
17
doc/docs.md
17
doc/docs.md
@ -5306,6 +5306,23 @@ An attribute is a compiler instruction specified inside `[]` right before a
|
|||||||
function/struct/enum declaration and applies only to the following declaration.
|
function/struct/enum declaration and applies only to the following declaration.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
|
// [flag] enables Enum types to be used as bitfields
|
||||||
|
|
||||||
|
[flag]
|
||||||
|
enum BitField {
|
||||||
|
read
|
||||||
|
write
|
||||||
|
other
|
||||||
|
}
|
||||||
|
|
||||||
|
fn example_enum_as_bitfield_use() {
|
||||||
|
assert 1 == int(BitField.read)
|
||||||
|
assert 2 == int(BitField.write)
|
||||||
|
mut bf := BitField.read
|
||||||
|
bf.set(.write | .other)
|
||||||
|
assert bf.has(.read | .write | .other)
|
||||||
|
}
|
||||||
|
|
||||||
// Calling this function will result in a deprecation warning
|
// Calling this function will result in a deprecation warning
|
||||||
[deprecated]
|
[deprecated]
|
||||||
fn old_function() {
|
fn old_function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user