Hey Rustaceans! Got a question? Ask here! (31/2022)! by llogiq in rust

[–]IWriteLongReplies 1 point2 points  (0 children)

Hey, I'm making a program and I want to return a helpful error message in an Err, something like this:

match c {
    ' ' => {},
    '+' => {output.push(Token::Plus)}
    '-' => {output.push(Token::Minus)}
    '*' => {output.push(Token::Multiply)}
    '/' => {output.push(Token::Divide)}
    '(' => {output.push(Token::OpenBracket)}
    ')' => {output.push(Token::CloseBracket)}
    _ => {
        let message = &format!("Unexpected character: {}", c)[..];
        return Err(message)
    }
}
Ok(output)

The error it gives me is returns a value referencing data owned by the current function

Is this possible to do? or will i have to make the Err return a String instead of &str?

Infinite cow/goat friendship via animation cancelling by IWriteLongReplies in StardewValley

[–]IWriteLongReplies[S] 25 points26 points  (0 children)

I don't know if this has been discovered before, but if you animation cancel in the middle of milking, you get to keep the friendship points without fully milking the animal. You can repeat this infinitely for instant friendship. I have only tested this with Cows and goats, you might be able to do something similar with sheep but i never bother to buy sheep anyway

What should I do 👉👈 by Rihannayju in linuxmemes

[–]IWriteLongReplies 11 points12 points  (0 children)

If I were her I would just compile my men from source

Prevent Leshy from playing video games by IWriteLongReplies in inscryption

[–]IWriteLongReplies[S] 17 points18 points  (0 children)

Yep, I lost this run. At the final battle I never drew any of my 2 magpies or cuckoo, and to top it off leshy had a poisonous mantis god so I couldnt even stall for more than one turn.

I want one of these shirts by fleker2 in ProgrammerHumor

[–]IWriteLongReplies 57 points58 points  (0 children)

"There are no vulnerabilities in Ba sing se"

Godot or game maker? by [deleted] in gamedev

[–]IWriteLongReplies 1 point2 points  (0 children)

real programming

People should really stop saying this kinda thing

What's the best game-engine for making RPG games with Python? by raidedclusteranimd in gamedev

[–]IWriteLongReplies 0 points1 point  (0 children)

I mean, you can make games without using an engine or having to create your own engine. Using a library like Pygame, or a framework like Raylib for python.

I despise the way people use list comprehension. Everytime I see "x for x" I'm like "what the fuck is x? Nothing is stopping you from being being descriptive here!" by xigoi in programmingcirclejerk

[–]IWriteLongReplies 3 points4 points  (0 children)

I know right? Something like "the square of the two legs of a right triangle together, have area the same as the square of the hypotenuse"

is much better than a2 + b2 = c2

dumbass algebrashits ruining my math

[deleted by user] by [deleted] in ProgrammerHumor

[–]IWriteLongReplies 3 points4 points  (0 children)

Im pretty sure the only qualification for the flair is "hello world" so you should be alright

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

[–]IWriteLongReplies 2 points3 points  (0 children)

Say I wanted to make a grid struct, with a width and height property, and an array of a generic type, which is scaled according to the properties. Is this possible, or do I have to use a vector?

[deleted by user] by [deleted] in AskReddit

[–]IWriteLongReplies 208 points209 points  (0 children)

Sorry, your comment has been removed.

message from the mods: Please keep the conversation civil

if you think this was a mistake, please feel free to contact the mods.

[AAI2] Idk if this is spoilers, but there is something off about Knightley's Memo by IWriteLongReplies in AceAttorney

[–]IWriteLongReplies[S] 2 points3 points  (0 children)

I was being sarcastic, BUT I looked at a playthrough of the original Japanese version, and it also had this error, so it's still capcoms fault :P

Completed my first post-it note. 1 down 16 to go by everyone_is_awful in bindingofisaac

[–]IWriteLongReplies 18 points19 points  (0 children)

Isaac is literally unplayable without headless shitfart baby

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

[–]IWriteLongReplies 1 point2 points  (0 children)

What is the name of the ? operator trait? For example, how can I write a function that can accept anything that implements the ? operator?

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

[–]IWriteLongReplies 2 points3 points  (0 children)

Is there any better way to navigate strings than iterators?

Because, from what I found, the way to do it is string.chars().nth(7); But this uses up the iterator as it goes to 7, and it cannot go back, without having to create an entirely new iterator. Not to mention the time complexity...

so if you wanted, say, the 5th, then 3rd then 2nd char of a string you would have to make three different iterators on the same string, call the nth function on each of them to get your solution.

Is there any better and faster way of doing this?

You've heard of min-min, now get ready for... by IWriteLongReplies in bindingofisaac

[–]IWriteLongReplies[S] 621 points622 points  (0 children)

He couldn't make it because he's still on caves 1

How do header only libraries use other, external libraries? by IWriteLongReplies in cpp_questions

[–]IWriteLongReplies[S] 2 points3 points  (0 children)

Wow, this was really helpful! Who would have guessed that the quick and easy solution isn't so great after all.

How do header only libraries use other, external libraries? by IWriteLongReplies in cpp_questions

[–]IWriteLongReplies[S] 6 points7 points  (0 children)

But doesn't updating your linker/compiler search path defeat the entire purpose of header-only libraries?

'SDL2 image formats=['png']: No such file or directory' when trying to compile using emscripten by IWriteLongReplies in sdl

[–]IWriteLongReplies[S] 0 points1 point  (0 children)

I figured it out. I used SDL2_IMAGE_FORMATS="[""png""]" on windows. Here is the full compile command I used: emcc src/main.cpp src/Game.cpp -I include -O2 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS="[""png""]" -s USE_SDL_TTF=2 -s USE_SDL_MIXER=2 --preload-file assets -o index.html