| 1 | module builtin |
| 2 | |
| 3 | // tos creates a V string, given a C style pointer to a 0 terminated block. |
| 4 | // Note: the memory block pointed by s is *reused, not copied*! |
| 5 | // It will panic, when the pointer `s` is 0. |
| 6 | // See also `tos_clone`. |
| 7 | @[unsafe] |
| 8 | pub fn tos(s &u8, len int) string { |
| 9 | if s == 0 { |
| 10 | panic('tos(): nil string') |
| 11 | } |
| 12 | return string{ |
| 13 | str: unsafe { s } |
| 14 | len: len |
| 15 | } |
| 16 | } |
| 17 |