Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Almost. dbg! also shows the statement in addition to what it evaluates too. That is:

  dbg!(n * factorial(n - 1))
shows up as:

  [src/main.rs:5] n * factorial(n - 1) = 2
  [src/main.rs:5] n * factorial(n - 1) = 6
  [src/main.rs:5] n * factorial(n - 1) = 24
Although, IIRC there was some crazy dumper module by dconway (who else) that worked similar to this, but I don't recall if it returned the value.

...

So, I just looked it up, and I found it. Actually, Damien wrote two. One that he updated from 2014 to 2016, and one he started in 2017 and has maintained to the present. I have no idea the reason for that.

1: https://metacpan.org/pod/Data::Show

2: https://metacpan.org/pod/Data::Dx



Hehe nice ones, thanks for the links! :)

Yep leave it Damien. I remember he did something similar for a test module where it would show the expressions that were evaluated in the test failure output.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: