Things you can’t do in Rust: variadic functions

Written by andrew_lucker | Published 2017/12/05
Tech Story Tags: programming | c | rust | software-developmen | computer-science

TLDRvia the TL;DR App

I love Rust and want it to be better. The dev teams know about all issues presented. I just want to generate discussion and enthusiasm for making a good language better.

#![feature(c_variadic)]#[no_mangle]pub unsafe extern "C" fn func(fixed: u32, mut args: ...) {let x: u8 = args.arg();let y: u16 = args.arg();let z: u32 = args.arg();println!("{} {} {} {}", fixed, x, y, z);}

Result (compile time error):

error[E0554]: #[feature] may not be used on the stable release channel|1 | #![feature(c_variadic)]| ^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error(s)

Rust has variadic macros. Rust can use C variadic functions. RFC 2137 covers only the case of defining variadic functions from within Rust. This is hard to think about garbage collection and lifetimes, so this feature may get restricted to ground types or similar compromises. Maybe this is just overlapping with macros and the feature is unnecessary.


Published by HackerNoon on 2017/12/05