News for hackers. Stuff that matters.
Re:My Struggles with Rust by bpicolo on Sunday May 07, 2017 @10:53AM (#14285732)
4 chained function calls from config -> read a key from it is quite an ask. Though I realize there's reason for it. There are many cases I'd be happy to have panics occur for invariants. config.strictString('foo') or something of that nature seems like it could be a more ergonomic choice in cases like thise.
Re:My Struggles with Rust by bluejekyll on Sunday May 07, 2017 @10:58AM (#14285758)
What he is showing is how someone who knows Rust well, would potentially approach this problem.

What you're point out is that it's a large bar to ask a new comer to the language to do this because it requires a deeper understanding of the language to use.

Is it not appropriate to show that you can reduce the complexity of a program by using other features of the language?

It's not significantly different from reducing

   x + x + x + x
To

   4x
Re:My Struggles with Rust by jackcviers3 on Sunday May 07, 2017 @11:05AM (#14285782)
Each function call is a transformation on the previous argument. Whether or not you assign the results to a variable first before calling the second doesn't change the behavior of the code.

But yes, it does appear that the config library needs an extra wrapper that loads from files and returns configs (in a context) that does the common work for you.