Warning
This post was published 52 days ago. The information described in this article may have changed.
If I compile the following cargo_test/src/main.rs:
fn main() {
let v : Vec<u32> = vec![1, 2, 3];
println!( "{:?}", v);
}
And then run the following commands in the cargo_test directory
lldb target/debug/cargo_test
b main.rs:4
run
p v
I get the output
(lldb) print v
(alloc::vec::Vec<unsigned int, alloc::alloc::Global>) {
buf = {
inner = {
ptr = {
pointer = (pointer = "\U00000001")
_marker = {}
}
cap = (__0 = 3)
alloc = {}
}
_marker = {}
}
len = 3
}
If I try to print the first element of v I get
(lldb) p v[0]
˄
╰─ error: type 'alloc::vec::Vec<unsigned int, alloc::alloc::Global>' does not provide a subscript operator
(lldb)
2 posts - 2 participants
🏷️ rust_feed