~/talk

Replacing #[cfg] with Traits: The Inlinable Dyn Extension Trait Pattern

links:none on file
slides:none on file

Compares six concrete implementations (cfgs, sidecar flags, option-args, function-pointer tables, trait-backed tables, plus a try_as_dyn variant) and shows the inlinable dyn extension trait pattern used for ~5–6 years in gdbstub with reproducible benchmarks and assembly analysis; rustc optimizes to zero-cost via dead-code-elimination and devirtualization so dyn-backed extension traits compile away in release, yielding compile-time capability checks while keeping runtime dynamism, though a remaining pitfall is forgetting to wire an impl and try_as_dyn is still a nightly, shifting feature.

AI-written summary · about

  1. 0:00Introduction and motivation
  2. 1:56Target controller libraries explained
  3. 5:21Architectural pressures in protocol libraries
  4. 8:46Six ways to implement the target trait
  5. 10:37First approach using cfg gates
  6. 13:14Limitations of cfg-based approach
  7. 13:37Sidecar methods for capability reporting
  8. 16:33Option-based handler sniffing
  9. 18:57Function pointer tables approach
  10. 23:01Inlinable dyn extension trait pattern
  11. 26:44Transferability to other domains
  12. 28:12Nightly try_as_dyn feature
  13. 30:33Q&A session
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.