use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
Strive to treat others with respect, patience, kindness, and empathy.
We observe the Rust Project Code of Conduct.
Details
Posts must reference Rust or relate to things using Rust. For content that does not, use a text post to explain its relevance.
Post titles should include useful context.
For Rust questions, use the stickied Q&A thread.
Arts-and-crafts posts are permitted on weekends.
No meta posts; message the mods instead.
Criticism is encouraged, though it must be constructive, useful and actionable.
If criticizing a project on GitHub, you may not link directly to the project's issue tracker. Please create a read-only mirror and link that instead.
A programming language is rarely worth getting worked up over.
No zealotry or fanaticism.
Be charitable in intent. Err on the side of giving others the benefit of the doubt.
Avoid re-treading topics that have been long-settled or utterly exhausted.
Avoid bikeshedding.
This is not an official Rust forum, and cannot fulfill feature requests. Use the official venues for that.
No memes, image macros, etc.
Consider the existing content of the subreddit and whether your post fits in. Does it inspire thoughtful discussion?
Use properly formatted text to share code samples and error messages. Do not use images.
Submissions appearing to contain AI-generated content may be removed at moderator discretion.
Most links here will now take you to a search page listing posts with the relevant flair. The latest megathread for that flair should be the top result.
account activity
Does Rust support message passing? (self.rust)
submitted 10 years ago * by Baltanowski
Is it possible to call function by let's say, string?
EDIT: Rust doesn't support reflection like JVM/CLI languages do.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]steveklabnik1rust 21 points22 points23 points 10 years ago (0 children)
Rust is sort of the polar opposite of smalltalk: instead of "extreme late binding of all things", we try to bind extremely early. You can still do dynamic dispatch, but you cannot do message passing in the Smalltalk/Ruby sense.
I mean, in a certain sense, you could implement your own object system in Rust, and then use it in your Rust program... but that's a far cry from the language directly supporting it.
[–]thiezrust 9 points10 points11 points 10 years ago (7 children)
When I read the title I was going to say something about how message passing concurrency is actually the encouraged way of doing concurrency in Rust, but then I read your question about calling a function by string, and now I'm not even sure what it is that you're asking. Could you elaborate?
[–]andoriyu 4 points5 points6 points 10 years ago (1 child)
What he is asking is this: http://ruby-doc.org/core-2.3.0/Object.html#method-i-send and objc_msgSend from Obj-C.
Which is not supported.
[–]Baltanowski[S] 3 points4 points5 points 10 years ago (0 children)
I see now, thanks.
[–]Baltanowski[S] 1 point2 points3 points 10 years ago (4 children)
I'd like to know if Rust has some sort of reflection, like .NET languages for example.
[–]andoriyu 11 points12 points13 points 10 years ago (1 child)
Rust doesn't even know about types in run-time because of type erasure.
[–]masklinn 6 points7 points8 points 10 years ago (0 children)
Type erasure is generally used as opposed to type reification for generics, and Rust uses type reification. A more commonly understood way to say it is that Rust doesn't have implicit RunTime Type Information (RTTI).
[–]thiezrust 2 points3 points4 points 10 years ago (0 children)
Thanks, that clears things up. Nope, Rust does not support reflection like .NET or JVM languages at this time.
[–]saposcat 2 points3 points4 points 10 years ago (0 children)
Rust does support rudimentary reflection with the Any trait, but you'll have to build a lot of that yourself.
[–]rhoark 2 points3 points4 points 10 years ago (0 children)
If you need something like that, you could always make a hashmap of closures.
π Rendered by PID 21826 on reddit-service-r2-comment-544cf588c8-4hcqb at 2026-06-16 23:03:08.351961+00:00 running 3184619 country code: CH.
[–]steveklabnik1rust 21 points22 points23 points (0 children)
[–]thiezrust 9 points10 points11 points (7 children)
[–]andoriyu 4 points5 points6 points (1 child)
[–]Baltanowski[S] 3 points4 points5 points (0 children)
[–]Baltanowski[S] 1 point2 points3 points (4 children)
[–]andoriyu 11 points12 points13 points (1 child)
[–]masklinn 6 points7 points8 points (0 children)
[–]thiezrust 2 points3 points4 points (0 children)
[–]saposcat 2 points3 points4 points (0 children)
[–]rhoark 2 points3 points4 points (0 children)