No dead code for types that implement traits that construct or read from them

⚓ rust    📅 2025-05-20    👤 surdeus    👁️ 3      

surdeus

Warning

This post was published 40 days ago. The information described in this article may have changed.
struct Test(bool);

impl AsRef<bool> for Test {
    fn as_ref(&self) -> &bool {
        &self.0
    }
}

impl From<bool> for Test {
    fn from(value: bool) -> Self {
        Self { 0: value }
    }
}

fn main() {}
   Compiling playground v0.0.1 (/playground)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.74s

Why is there no dead_code warning (never constructed, never read)?
There should be.

2 posts - 2 participants

Read full topic

🏷️ rust_feed