Been waiting for this. Great video! The disassemble command for anyone curious was: "objdump --disassemble=g ./path/to/binary". Do you have any opinions on cargo-asm??
@fasterthanlime
3 жыл бұрын
cargo-asm looks really neat, I haven't time to play with it yet!
@jhpratt
3 жыл бұрын
@@fasterthanlime You should check it out! It runs in release mode by default, too, so it eliminates any debug stuff (in this case the stack allocations that you noted).
@tudbut
Жыл бұрын
You could actually do this without any unsafe code! fn main() { let x = "a"; #[cfg(feature = "this_feature_name_is_wayyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy_too_long")] let x = "b"; println!("{x}"); }
@0LoneTech
Жыл бұрын
That's neat. I was thinking similarly, having the argument shadow a global value if it existed.
@nachiketkanore
Жыл бұрын
Elegant
@AlfW
3 жыл бұрын
I was just laughing insanely while watching your video. What's wrong with me? I found your cheat solution already genius.
@gadiguibou
3 жыл бұрын
Really clever solution! I'm curious how long it took you to find a rustfmt issue that affected code functionality?
@fasterthanlime
3 жыл бұрын
Not too long! I did it on my phone while taking a walk. That issue isn't too high priority though, if you mess with the attribute length even a little it stops breaking - it's very specific
@kebbotnet4170
3 жыл бұрын
Welcome back Amos!
@dorktales254
3 жыл бұрын
I see vscode is demanding an update
@fasterthanlime
3 жыл бұрын
I didn't even see that! I'm usually very good with updates. What time is that visible in the video?
@zokalyx
Жыл бұрын
@@fasterthanlime not that it matters, but, during the whole video there is a notification on the bottom left
@CyborusYT
2 жыл бұрын
Simpler answer: ``` fn main() { #[cfg( feature = "holy_heck_this_is_a_long_feature_name_who_in_their_right_mind_would_name_something_this_seriously_this_is_absurd" )] { println!("b"); return; } println!("a"); } ``` (but it seems that issue has been patched, at least in the playground)
@fasterthanlime
2 жыл бұрын
That bug is not as easy to exploit as it seems, even slight changes broke it. Also your solution is incorrect, it should never print *both* a and b 😬
@CyborusYT
2 жыл бұрын
@@fasterthanlime Oh, it's not a minimum length, it's a specific length? Yeah, that's what the `return` is for
@jackmaguire8634
2 жыл бұрын
What extension are you using for the errors showing up in code?
@fasterthanlime
2 жыл бұрын
It's called "Error Lens".
@ISSOtm
3 жыл бұрын
Awesome video! (AT&T syntax, though? 😥)
@fasterthanlime
3 жыл бұрын
Haha I recently set up my computer again and forgot to alias objdump to always output Intel syntax. When I realized that, it was too late. Now we all have to live with this video forever. I hope in time, y'all will find it in your heart to forgive me.
@kintrix007
Жыл бұрын
@@fasterthanlime What is wrong with AT&T syntax? Or did I accidentally just step foot between the war of the two cults?
@thetos
Жыл бұрын
I feel like you could have done something a lot simpler for that solution, you could have had a function taking 2 bools as arguments, the first one would be behind the feature, the second one would always be there, by then unsing the transmute trick to get a function pointer that you can always call, you could have a function which always accepts 2 parameters. you could then call it with one being true, the other being false. To know if the first parameter exists, you only need to read the value of the second parameter. If you call the pointer with true then false, the second parameter will be false if the code has been formated, and true if it has not. then what you do with this boolean is up to you, you can straight up use it in the function to print or return it to print from another function. I guess it's not involving as much deep knowledge about low level and how languages translate to machine code, and may even not let you be as "poetic" with the final presentation, but it should be functional.
@WitherBossEntity
Жыл бұрын
You don't even need unsafe, you can just put Deref to work: struct Foo; impl Foo { fn print(&self) { println!("a"); } } struct Wrapper(Foo, F); impl std::ops::Deref for Wrapper { type Target = Foo; fn deref(&self) -> &Foo { &self.0 } } impl Wrapper where F: Fn(()) { fn print(&self) { println!("b"); } } Sadly the compiler doesn't consider Fn() and Fn(bool) to be disjunct, that would have made it even easier.
@modolief
Жыл бұрын
Bravo!
@SangharshSeth
Жыл бұрын
hi
@Rgoiwnes
Жыл бұрын
"I think macabre is a fun word..." That's rather grim don't you think?
@DaniPardo
3 жыл бұрын
Good stuff. But personally, I found it too fast paced (probably it's my brain which is too slow), and found myself pausing the video every 5 seconds to read what you just wrote and digesting what you just said in the prev 5secs
@fasterthanlime
3 жыл бұрын
Yeah, I know what you mean. I almost rerecorded everything but instead opted to do a lot of editing instead. It's hard to find a rhythm that works for everyone but I think I can do better than this. Pausing is fine and good though!
@gregoryholder2423
Жыл бұрын
This video is so cursed, I love it
@CielMC
Жыл бұрын
Calling f as an unargumented function is definitely unsound...
@swanandx
3 жыл бұрын
Intresting stuff presented in great way! Nice video.
@Chrizz604
2 жыл бұрын
Could you make a video about tonic?
@the_kovic
Жыл бұрын
This is probably Rust sacrilege but I *strongly* prefer having opening braces to a block be on a new line rather than at the end of the current line. I tried customizing rustfmt but I couldn't find a configuration that would automate formatting braces in a way that I like.
@fasterthanlime
Жыл бұрын
I believe this does what you want (Allman brace style) github.com/somethingwithcode/rustformat/blob/master/source/rustfmt.toml but 1) it's from 2017, YMMV, and 2) of all the hills to die on!! I'm a professional hill-deceased and even I have given up on a preferred style in the interest of easy collaboration 😬
Пікірлер: 38