You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use derive_more::Display;#[derive(Display,Debug)]#[display("{head}.{tail}")]structStruct{head:char,tail:str,}fnmain(){let dat = [51i32,3028017];let s = unsafe{&*(&rawconst dat as*const[i32]as*constStruct)};println!("{:?}", s);println!("{}", s);}
The derived Debug impl prints Struct { head: '3', tail: "14" } but the Display impl does not compile.
error[E0277]: the size for values of type `str` cannot be known at compilation time --> src/main.rs:3:10 |3 | #[derive(Display, Debug)] | ^^^^^^^ doesn't have a size known at compile-time4 | #[display("{head}.{tail}")] | ------ required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `str`note: required by an implicit `Sized` bound in `derive_more::core::fmt::rt::Argument::<'_>::new_display` --> $RUSTUP_HOME/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/rt.rs:113:24 |113 | pub fn new_display<T: Display>(x: &T) -> Argument<'_> { | ^ required by the implicit `Sized` requirement on this type parameter in `Argument::<'_>::new_display` = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the derive macro `Display` (in Nightly builds, run with -Z macro-backtrace for more info)
The text was updated successfully, but these errors were encountered:
The derived Debug impl prints
Struct { head: '3', tail: "14" }
but the Display impl does not compile.The text was updated successfully, but these errors were encountered: