Concatenating at compile time

⚓ Rust    📅 2025-10-01    👤 surdeus    👁️ 7      

surdeus

Suppose I have a trait like this:

trait Trait {
   const X: &[u8];
}

Is there a way to make something like the following work? Since all sizes are known at compile-time it seems to me that it should, but no luck so far...

struct Bigger<T> {...};

impl<T: Trait> Trait for Bigger<T> {
   const X: b"bigger" + T::X;
}

1 post - 1 participant

Read full topic

🏷️ Rust_feed