I genuinely kind of surprised that this program compiles in #rust. I get *why* it does (trait objects!) but it still seems a little weird/like support for heterogeneous arrays:

use std::fmt::Debug
fn main() {
let mut v: Vec<dyn Debug> = Vec::new();
println!("{}", v);

@codesections no way this compiles, you must mean Vec<&dyn Debug>, right??


@codesections besides, this is exactly how heterogeneous arrays work in JavaScript and the like: they don't store values in the array, they store references to them, cause otherwise indexing the array would be very slow

Sign in to participate in the conversation
Mastodon for Tech Folks

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!