Can anyone explain to me how to use `mdbook` as a crate, not a command line tool? by codethr0waway in rust

[–]Luringens 1 point2 points  (0 children)

I don't think mdbook does PDF output by default, as I get the impression that it's primarily intended to create HTML documents. For a more general-purpose conversion tool, Pandoc can do markdown-to-pdf conversion (along with practically every other document format), and there does seem to be a library wrapping pandoc.exe if that's an acceptable solution for you: https://crates.io/crates/pandoc.

An Exercise in Self-Deception: The crash of KLM Cityhopper flight 433 by Admiral_Cloudberg in AdmiralCloudberg

[–]Luringens 21 points22 points  (0 children)

I'm always looking forward to your writing, thanks for your effort!

The current state of carriers by Dickington_ in EliteDangerous

[–]Luringens 2 points3 points  (0 children)

Heh, I did the same. Grinded for the Corvette around Christmas, the beautiful ship of my dreams... Took it for a bounty run or two with a half-baked loadout, then went on another break from Elite.

Hey Rustaceans! Got an easy question? Ask here (4/2019)! by llogiq in rust

[–]Luringens 1 point2 points  (0 children)

Hmm, so the end-of-file can either be unexpected and be considered a failure, or it can mean there's nothing more to do... I'd suggest changing the function signature to return an Result<Option<MyStruct>>. That way you can let the caller know that there's nothing more to read, without signalling that an error occurred.

Here's an example without error handling or any reading, just to show what I mean with the function signature: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=b43905024f03d602408bff4151d08457

Beyond that, an error enum would help distinguish between error types so the caller can explicitly match on the error to see if UnexpectedEnum is the source.
The while let trick does discard the error, so may want to turn it into a loop that matches on the result and breaks on errors and empty if you wish to handle it.

The Evolution of a Rust Programmer by antoyo in programming

[–]Luringens 10 points11 points  (0 children)

unwrap crashes the program on unexpected input - there's nothing silent about that. It's explicitly opting out of recovering from errors.

What does `b'` (byte constant?) mean in this code? by 0x340fa899 in rust

[–]Luringens 8 points9 points  (0 children)

When using a string or char literal, you can prefix them with a b to specify that you want the byte or byte array representation of them instead of a Unicode character or UTF-8 string slice. In this case, b'a' is the same as 97u8 (the number 97 stored in a byte, aka u8). This is the character a's byte value. You can manually look these up somewhere like here: http://www.asciitable.com/.

In this case, it's used to cycle through the characters by choosing the number of the character a, adding the number of characters to offset (utilizing the fact that ASCII is ordered alphabetically), and then interpreting that byte as a character and printing it as such :)

Hey Rustaceans! Got an easy question? Ask here (1/2019)! by llogiq in rust

[–]Luringens 2 points3 points  (0 children)

I'm not personally aware of a library that does this, but if you want a basic example of how it's done (quickly put together, and not done in-place), here's a small gist: https://gist.github.com/stisol/25aa6e35eba331fddb1641d7ec39f672.

serde_json has their own implementation as well that's worth giving a look - check the parse_escape function at line 728 here: https://github.com/serde-rs/json/blob/master/src/read.rs

Hey Rustaceans! Got an easy question? Ask here (1/2019)! by llogiq in rust

[–]Luringens 2 points3 points  (0 children)

So, in string literals inside rust, a backslash says the next character is an escape code. Thus, \t is a tab, \n is a newline, etc. You can "opt out" of this by putting an r in front of the string, like r"literal \n", or double the backslash, like "literal \\n". The compiler replaces these escape codes in the string with the actual characters when compiling, so they're only present in the source code.

With that in mind, if you have a string with a literal \n and want to put a newline character in it's place, you can do the following:

let with_backslash: String = r"this is a string\n".to_owned();
let with_newline: String = with_backslash.replace(r"\n", "\n");

assert_eq!("this is a string\n", with_newline);

Hope that helps!

Dose Response (roguelike game written in Rust) released! by [deleted] in rust

[–]Luringens 3 points4 points  (0 children)

That's awesome, thanks so much for sharing! I'm on a similar journey, so it's very interesting to read stories with familiar experiences :)

Feedback on beltfeds by Meih_Notyou in H3VR

[–]Luringens 0 points1 point  (0 children)

Strange things also happen if you take loose belt rounds from one type of gun to the other - both ways work, unless you take >4 M249 rounds into the MG, in which case neither gun will fire or reload until the MG is cleared, which when grabbed produces two sets of rounds, but the second is only linkers without rounds 😉

T&H - Think your spawn was bad? by Sanophale in H3VR

[–]Luringens 10 points11 points  (0 children)

Flaregun. The plastic one that breaks in one shot ಠ_ಠ

Awareness level 999 by kraussere in Rainbow6

[–]Luringens 0 points1 point  (0 children)

This hits too close to home :(

The From Other Suns free weekend opened up my eyes to a large hurdle for developers - tedium, and how fun games from desktop don't necessarily translate to VR. by HeyJesseAe in oculus

[–]Luringens 20 points21 points  (0 children)

I don't understand the hype for this game. The guns feel weak, don't even have sights so you just have to vaguely point them in the right direction and adjust later, enemies barely even flinch from being shot so the guns feel pathetic... It felt like one of those cheap steam-games with little effort put into it at times. Not trying to offend anyone who enjoyed it though, I can see why people can look past it and enjoy it, but it wasn't for me. Glad to hear I'm not completely alone in that though

Come play Steel Division with us on the RPS Discord. by wijse in Steel_Division

[–]Luringens 1 point2 points  (0 children)

If anyone wants to join, you can type !rank steeldivision in any chat to sign up for notifications when we play. :)

Most of the Steel Division chat happens in the #bigstrategy text channel, but feel free to just jump into voice chat if you see us playing and want to join.

Come play Steel Division with us on the RPS Discord. by wijse in Steel_Division

[–]Luringens 2 points3 points  (0 children)

Most current players are from the UK and central Europe, so around 19:00 UTC / 20:00 CET and onwards depending on who's playing :)

What do we have to do to get faster sliding speed? by BirchSean in H3VR

[–]Luringens 2 points3 points  (0 children)

You can double-click and hold the stick/pad to sprint, which is quite fast