1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: check generic struct init without type parameter (#13404)

This commit is contained in:
yuyi
2022-02-09 20:06:45 +08:00
committed by GitHub
parent 356ccf247f
commit 4be3c92640
10 changed files with 77 additions and 27 deletions

View File

@@ -46,7 +46,7 @@ pub fn (list DoublyLinkedList<T>) last() ?T {
// push_back adds an element to the end of the linked list
pub fn (mut list DoublyLinkedList<T>) push_back(item T) {
mut new_node := &DoublyListNode{
mut new_node := &DoublyListNode<T>{
data: item
}
if list.is_empty() {
@@ -63,7 +63,7 @@ pub fn (mut list DoublyLinkedList<T>) push_back(item T) {
// push_front adds an element to the beginning of the linked list
pub fn (mut list DoublyLinkedList<T>) push_front(item T) {
mut new_node := &DoublyListNode{
mut new_node := &DoublyListNode<T>{
data: item
}
if list.is_empty() {
@@ -149,7 +149,7 @@ fn (mut list DoublyLinkedList<T>) insert_back(idx int, item T) {
// |next|---->|next|
// |prev|<----|prev|
// ------ ------
new := &DoublyListNode{
new := &DoublyListNode<T>{
data: item
next: node
prev: prev
@@ -176,7 +176,7 @@ fn (mut list DoublyLinkedList<T>) insert_front(idx int, item T) {
// |next|---->|next|
// |prev|<----|prev|
// ------ ------
new := &DoublyListNode{
new := &DoublyListNode<T>{
data: item
next: next
prev: node

View File

@@ -61,7 +61,7 @@ pub fn (list LinkedList<T>) index(idx int) ?T {
// push adds an element to the end of the linked list
pub fn (mut list LinkedList<T>) push(item T) {
new_node := &ListNode{
new_node := &ListNode<T>{
data: item
}
if list.head == 0 {
@@ -124,7 +124,7 @@ pub fn (mut list LinkedList<T>) insert(idx int, item T) ? {
if idx == 0 {
// first node case
list.head = &ListNode{
list.head = &ListNode<T>{
data: item
next: node
}
@@ -132,7 +132,7 @@ pub fn (mut list LinkedList<T>) insert(idx int, item T) ? {
for i := 0; i < idx - 1; i++ {
node = node.next
}
node.next = &ListNode{
node.next = &ListNode<T>{
data: item
next: node.next
}