I'm learning howto write low-level stuff in Rust and I was trying to display members of following structs:
use std::{ptr::NonNull, marker::PhantomData};
pub struct Node<T> {
value: T,
pub(crate) next: Option<NonNull<Node<T>>>,
pub(crate) prev: Option<NonNull<Node<T>>>,
}
pub struct LinkedList<T> {
pub(crate) head: Option<NonNull<Node<T>>>,
pub(crate) tail: Option<NonNull<Node<T>>>,
marker: PhantomData<T>,
}
In VSCode I can only see value member but not next prev members:
Under rust-gdb/rust-lldb I'm a little bit lost and cannot display those members at all:
(gdb) p list
$1 = linked_list::linked_list::LinkedList<i32> {head: core::option::Option<core::ptr::non_null::NonNull<linked_list::linked_list::Node<i32>>>::Some(core::ptr::non_null::NonNull<linked_list::linked_list::Node<i32>> {pointer: 0x7ffff0000df0}), tail: core::option::Option<core::ptr::non_null::NonNull<linked_list::linked_list::Node<i32>>>::Some(core::ptr::non_null::NonNull<linked_list::linked_list::Node<i32>> {pointer: 0x7ffff0000dd0}), marker: core::marker::PhantomData<i32>}
(gdb) p list.head
$2 = core::option::Option<core::ptr::non_null::NonNull<linked_list::linked_list::Node<i32>>>::Some(core::ptr::non_null::NonNull<linked_list::linked_list::Node<i32>> {pointer: 0x7ffff0000df0})
(gdb) p list.head.next
Attempting to access named field next of tuple variant core::option::Option<core::ptr::non_null::NonNull<linked_list::linked_list::Node<i32>>>::Some, which has only anonymous fields
How can I display list.head.next/list.head.prev members and check where they actually point to?
BR,
Dariusz