I'm trying to understand #![feature(specialization)] vs. #![feature(min_specialization)] to inform the design of my types, but I haven't been able to find any novice-accessible documentation. How do the two differ?
Specifically, I expected the following (playground) to be straightforward specialization, but it does not work with min_specialization. Why not?
#![feature(min_specialization)]
trait A {}
trait B: A {}
struct Sa;
impl A for Sa {}
struct Sb;
impl A for Sb {}
impl B for Sb {}
trait X {
fn method(&self);
}
impl<T: A> X for T {
default fn method(&self) {
println!("default");
}
}
// error: cannot specialize on trait `B`
// --> src/main.rs:29:13
// |
// 29 | impl<T: A + B> X for T {
// | ^
impl<T: A + B> X for T {
fn method(&self) {
println!("specialized");
}
}
fn main() {
Sa.method();
Sb.method();
}
4 posts - 3 participants
Read full topic
| # | Наименование новости | Тональность | Информативность | Дата публикации |
|---|---|---|---|---|
| 1 | Trait object with associated types in field - requires generic param? | 0 | 11.08 | 07-10-2026 |
| 2 | Strategies for dyn trait objects with optional behavior? | 0 | 7.12 | 06-10-2026 |
| 3 | Optimization of inlined functions returning Result? | 0 | 7.36 | 06-10-2026 |
| 4 | Type erasure and dyn lifetime in a NonNull/Box struct field | 0 | 8.55 | 04-10-2026 |
| 5 | Why no Dependent Matrix Type? | 0 | 5.16 | 08-10-2026 |
| 6 | Чудеса nightly, часть 1: на чём тайком держится stable Rust | 0 | 8.55 | 29-09-2026 |
| 7 | Rust Derive Macros: Why the Compiler Automatically Inlines Them | 0 | 9.29 | 07-10-2026 |
| 8 | Architecture review of a Hyper/Tower-based web framework (Toxi) | 0 | 15.46 | 06-10-2026 |
| 9 | Does my lockfree stack impl look correct? | 0 | 6.06 | 05-10-2026 |