alex

/

v Public
0 Issues 1 Contributor 0 Releases 4 Branches
Additions: 15 Deletions: 15 View patch
1 ```v
2 struct Node {
3 a &Node
4- b &Node = 0 // Auto-initialized to nil, use with caution!
5+ b &Node = unsafe { nil } // Auto-initialized to nil, use with caution!
6 }
7
8 // Reference fields must be initialized unless an initial value is declared.
9
1
2 struct App {
3 mut:
4- gg &gg.Context = 0
5+ gg &gg.Context = unsafe { nil }
6 radius f64 = 10.0
7 }
8
9 fn frame(mut app App) {
10 app.gg.begin()
11 app.gg.draw_circle_empty(150, 150, f32(app.radius), gx.blue)
12- app.gg.draw_text(20, 20, 'radius: $app.radius')
13+ app.gg.draw_text(20, 20, 'radius: ${app.radius}')
14 // app.gg.draw_text(20, 50, 'circle_segment_size: $circle_segment_size')
15 app.gg.end()
16 }
17
1
2 struct App {
3 mut:
4- tui &tui.Context = 0
5+ tui &tui.Context = unsafe { nil }
6 }
7
8 fn event(e &tui.Event, x voidptr) {
9
1 struct Node[T] {
2 pub mut:
3 val T
4- next &Node[T] = 0
5+ next &Node[T] = unsafe { nil }
6 }
7
8 fn new[T]() &Node[T] {
9
1 struct ListNode[T] {
2 pub mut:
3 val T
4- next &ListNode[T] = 0
5+ next &ListNode[T] = unsafe { nil }
6 }
7
8 fn (mut node ListNode[T]) test() &ListNode[T] {
9
1 struct List[T] {
2 pub mut:
3- head &ListNode[T] = 0
4+ head &ListNode[T] = unsafe { nil }
5 }
6
7 struct ListNode[T] {
8 pub mut:
9 value T
10- next &ListNode[T] = 0
11+ next &ListNode[T] = unsafe { nil }
12 }
13
14 fn list_new[T]() List[T] {
15
1 struct ListNode[T] {
2 mut:
3 val T
4- next &ListNode[T] = 0
5+ next &ListNode[T] = unsafe { nil }
6 }
7
8 fn create[T](arr []T) &List[T] {
9
1
2 struct List[T] {
3 pub mut:
4- head &ListNode[T] = 0
5+ head &ListNode[T] = unsafe { nil }
6 }
7
8 struct ListNode[T] {
9 pub mut:
10 value T
11- next &ListNode[T] = 0
12+ next &ListNode[T] = unsafe { nil }
13 }
14
15 pub fn list_new[T]() &List[T] {
16
1 struct Node[T] {
2 mut:
3 data T
4- next &Node[T] = 0
5+ next &Node[T] = unsafe { nil }
6 }
7
8 struct SinglyLinkedList[T] {
9 mut:
10- first_node &Node[T] = 0
11+ first_node &Node[T] = unsafe { nil }
12 }
13
14 fn init_singlylinkedlist[T](nodes ...Node[T]) SinglyLinkedList[T] {
15
1 struct Abc {
2 mut:
3 vptr voidptr
4- vptrptr &voidptr = 0
5- bptr &u8 = 0
6+ vptrptr &voidptr = unsafe { nil }
7+ bptr &u8 = unsafe { nil }
8 cptr &char = c'abcdef'
9 }
10