What does the trust mean by #[xxx]
or #![xxx]
as stated in the title?
For example,
https://rocket.rs/
It's like the one in this sample code.
#![feature(proc_macro_hygiene,decl_macro)]
# [macro_use] external crate rocket;
# [get("/hello/<name>/<age>")]
fn hello(name:String,age:u8) - > String {
format!("Hello,{}year old named{}!",age,name)
}
US>fnmain(){
rocket::ignite().mount("/", routes![hello]).launch();
}
I would appreciate it if you could let me know if there are any names attached to them.
Also, I usually use Ruby and JavaScript, so please let me know if there are any similar features.
I look forward to your kind cooperation.
rust
Something like #![hoge]
is called Inner attribute, which gives attributes to that scope.
For example, #![feature(proc_macro_hygiene,decl_macro)]
in the code indicated means "Enable the unstable features proc_macro_hygiene
and decl_macro
at this scope."
Something like #[fuga]
is called Outer attribute, which gives attributes to the item immediately after it.
For example, #[get("/hello/<name>/>age>")]
in the indicated code means "Register the item immediately following (in this case, the function hello
) as a handler for the specified URL."
(This get
attribute is a language function called attribute-like macro that Rocket uniquely defines.)
I just found out that the symbols and operators that appear frequently in Rust are summarized in The book's appendix.For your information.
https://doc.rust-lang.org/book/appendix-02-operators.html
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.