Skip to content

Commit

Permalink
doc: use u8 instead of byte
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed May 18, 2023
1 parent cc47c78 commit f67952f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Enum values now can have attributes.
- json: Enum value string serialization supports `[json:'alias']` to change its string values.
- Functions can now return fixed size arrays.
- The builtin websocket library is now thread safe.

## V 0.3.4

Expand Down
26 changes: 13 additions & 13 deletions doc/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ assert s.len == 10
arr := s.bytes() // convert `string` to `[]u8`
assert arr.len == 10
s2 := arr.bytestr() // convert `[]byte` to `string`
s2 := arr.bytestr() // convert `[]u8` to `string`
assert s2 == s
```

Expand All @@ -571,9 +571,9 @@ s[0] = `H` // not allowed

> error: cannot assign to `s[i]` since V strings are immutable
Note that indexing a string will produce a `byte`, not a `rune` nor another `string`. Indexes
correspond to _bytes_ in the string, not Unicode code points. If you want to convert the `byte` to a
`string`, use the `.ascii_str()` method on the `byte`:
Note that indexing a string will produce a `u8` (byte), not a `rune` nor another `string`. Indexes
correspond to _bytes_ in the string, not Unicode code points. If you want to convert the `u8` to a
`string`, use the `.ascii_str()` method on the `u8`:

```v
country := 'Netherlands'
Expand Down Expand Up @@ -2559,10 +2559,10 @@ Just like structs, unions support embedding.

```v
struct Rgba32_Component {
r byte
g byte
b byte
a byte
r u8
g u8
b u8
a u8
}
union Rgba32 {
Expand Down Expand Up @@ -3515,12 +3515,12 @@ Interfaces support embedding, just like structs:
```v
pub interface Reader {
mut:
read(mut buf []byte) ?int
read(mut buf []u8) ?int
}
pub interface Writer {
mut:
write(buf []byte) ?int
write(buf []u8) ?int
}
// ReaderWriter embeds both Reader and Writer.
Expand Down Expand Up @@ -5955,7 +5955,7 @@ Since V does not support overloading functions by intention there are wrapper fu
C headers named `atomic.h` that are part of the V compiler infrastructure.
There are dedicated wrappers for all unsigned integer types and for pointers.
(`byte` is not fully supported on Windows) – the function names include the type name
(`u8` is not fully supported on Windows) – the function names include the type name
as suffix. e.g. `C.atomic_load_ptr()` or `C.atomic_fetch_add_u64()`.
To use these functions the C header for the used OS has to be included and the functions
Expand Down Expand Up @@ -6393,7 +6393,7 @@ These can be converted to V strings with `string_from_wide(&u16(cwidestring))` .
V has these types for easier interoperability with C:
- `voidptr` for C's `void*`,
- `&byte` for C's `byte*` and
- `&u8` for C's `byte*` and
- `&char` for C's `char*`.
- `&&char` for C's `char**`
Expand Down Expand Up @@ -6431,7 +6431,7 @@ members of sub-data-structures may be directly declared in the containing struct
```v
struct C.SomeCStruct {
implTraits byte
implTraits u8
memPoolData u16
// These members are part of sub data structures that can't currently be represented in V.
// Declaring them directly like this is sufficient for access.
Expand Down

0 comments on commit f67952f

Please sign in to comment.