struct Item { int num; wl_list link; this(int num) { this.num = num; } } auto i1 = Item(1); auto i2 = Item(2); auto i3 = Item(3); wl_list lst; wl_list_init(&lst); wl_list_insert(&lst, &i1.link); wl_list_insert(&lst, &i2.link); wl_list_insert(&i2.link, &i3.link); int[] forw_arr; foreach(it; wl_range!(Item.link)(&lst)) { forw_arr ~= it.num; } assert(forw_arr == [2, 3, 1]); int[] back_arr; foreach_reverse(it; wl_range!(Item.link)(&lst)) { back_arr ~= it.num; } assert(back_arr == [1, 3, 2]);
Returns a range that iterates over a wl_list. The member alias and the passed list is the wl_list member in a container struct, and the front type of the range is the container itself.