Closed kevinburke closed 2 years ago
Let's give it a #[derive(Debug)]
Hmmm... if we add that, I get
rustls_str { data: 0x1027f29b4, len: 4, phantom: PhantomData }
when I try to print using debug formatting:
#[test]
fn test_rustls_str_debug() {
let s = "abcd";
let rs: rustls_str = s.try_into().unwrap();
let mut buf = String::new();
write!(buf, "{:?}", rs);
println!("{}", buf);
assert_eq!(3, 4)
}
So we get some more data, but the contents of the string - what I'm trying to print - I still get out a pointer, which is not great.
Ah, right, sorry - a derived Debug won't work here, you need to implement an actual Debug implementation, which turns the pointer and len into an &str
.
I'm writing a test in Rust that is trying to check a rustls_str, and it's trickier because it's difficult to print the contents of the str to the console.
It might be nice to implement one of
[derive(Debug)] for that struct
Open to any of these that you think would be best.