bitprophet,
@bitprophet@social.coop avatar

fuck meeeeeee did I miss this or does basically no beginner Rust material fucking show you the dbg!(foo) macro?!?!?!?!?!

Fuckers all telling me to use println!(“{:?}”, foo) instead like some kinda person who loves typing extra bullshit!!!

DrRac27,
@DrRac27@fosstodon.org avatar

@bitprophet its in the book chapter 5.2 ...

bitprophet,
@bitprophet@social.coop avatar

@DrRac27 so it is! sadly it's essentially a throwaway reference so easy to overlook. I'm mostly questioning why it's not the default for arbitrary examples of "print this value" in sample codeblocks. Could be the ownership thing, I guess, but.

juergen,

@bitprophet From personal experience with a #rust newbie (but otherwise experienced IT pro): dbg!() moves its argument, so without & the borrow checker will get you. Also, the output of dbg! is too obtrusive.

bitprophet,
@bitprophet@social.coop avatar

@juergen yea I’ve been noticing the move angle, which is an annoying downside, but still slightly less annoying than using println for the most trivial cases. I think. 🧐

juergen,

@bitprophet I always use println. Most of the time I print more than one value, and I try to keep it compact, in a single line.

bitprophet,
@bitprophet@social.coop avatar

@juergen yea, for anything nontrivial println is arguably more useful, but when you're doing real basic stuff and just want to see WHAT IS THE THING HERE, having to do a single “{:?}" was irritating and dbg helps with that 😂

  • All
  • Subscribed
  • Moderated
  • Favorites
  • rust
  • DreamBathrooms
  • ethstaker
  • thenastyranch
  • magazineikmin
  • modclub
  • rosin
  • khanakhh
  • osvaldo12
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • everett
  • ngwrru68w68
  • megavids
  • tacticalgear
  • InstantRegret
  • Leos
  • cubers
  • mdbf
  • normalnudes
  • tester
  • GTA5RPClips
  • provamag3
  • cisconetworking
  • anitta
  • JUstTest
  • lostlight
  • All magazines