News for hackers. Stuff that matters.
Re:Ill-Advised C++ Rant, Part 2 (2016) by LambdaComplex on Wednesday October 25, 2017 @03:51PM (#15553496)
I think Rust solves a lot of these problems.

> Calculating the size of a static array

some_array.len()

> Getting the maximum value of an enum

Rust's enums are strongly-typed (I think that's the right phrase), so this is a non-issue.

> Converting an enum to a string

impl Display for MyEnum (and then call to_string() on it)

> Converting a string to an enum

This could be tricky, since Rust enum variants can contain data. But if none of the variants contain data, it would be easy to make a method that returns a Result<MyEnum, CustomParseError>

> Binary file includes

include_bytes! macro (or the include_str! macro, depending on the exact scenario)

> Switch/case is still stupid

Pretty sure Rust's match is a lot better

Re:Ill-Advised C++ Rant, Part 2 (2016) by pcwalton on Wednesday October 25, 2017 @04:00PM (#15553593)
> This could be tricky, since Rust enum variants can contain data. But if none of the variants contain data, it would be easy to make a method that returns a Result<MyEnum, CustomParseError>

Usually when you want to convert a string to an enum, you're trying to build some kind of parser or deserialization library, in which nom or serde are the best choices. (Of course, C++ has several parser frameworks too.)

Re:Ill-Advised C++ Rant, Part 2 (2016) by LambdaComplex on Wednesday October 25, 2017 @04:13PM (#15553723)
Yeah, I would definitely be using serde in that case