Not sure what to do about @rustlang ... I can't figure out how to return a string from a function. How pathetic is that?
-
Show this thread
-
I really want to learn Rust, and I'm going through the tutorial. Maybe I'm just to used to JavaScript or something, but I get stuck not able to do fundamental / simple things, and I don't even know where to go from there.
1 reply 0 retweets 0 likesShow this thread -
Why doesn't `return "str"` work in a function? How do I return a string? I've tried removing "return," adding / removing semicolons, ... how do I figure out how to return a string in Rust?
2 replies 0 retweets 0 likesShow this thread -
-
Replying to @rustlang
I appreciate that; I was frustrated and maybe more whiny than I should have been. I’m trying to implement the 12 days of Christmas a la the tutorial. I can’t create a function that simple returns a string... not even `return "x"`.
1 reply 0 retweets 0 likes -
Replying to @ExplosionPills @rustlang
I’m trying to build a string. I’ve seen solutions that have functions that simply print it out, but I’m not satisfied with that or it wasn’t what I originally thought of.
1 reply 0 retweets 0 likes -
Replying to @ExplosionPills
Usually, if you’re building a string and want to return it, you use String. &str is for Ei slices, things like that. So you usually see it as an argument. It can sometimes be a return value, but that’s for more of when your struct has a String internally
2 replies 0 retweets 1 like -
Replying to @rustlang
Could you be more specific about what you mean by “use String” and what an Ei slice is?
1 reply 0 retweets 0 likes -
Replying to @ExplosionPills
Sorry, “Ei” was my phone having a mind of its own
2 replies 0 retweets 1 like
It should have been “literal”, no idea how that happened!
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.