I'm currently learning RUST, but I can't get out of the following error:
How can I get out of it?
error message
error:cannot find macro `mime` in this scope
-->src/main.rs:16:18
|
16 | response.set_mut (mime! (Text/Html; Charset=Utf8));
Related codes are as follows:
.toml
[package]
name = "iron-gcd"
version = "0.1.0"
authorities=["<>" ]
[Dependencies]
iron="0.5.1"
mime = "0.3.16"
router = "0.5.1"
urlencoded="0.5.0"
main
extern crate iron;
# [macro_use]extern rate mime;
useiron::prelude::*;
useiron::status;
US>fnmain(){
println!("Serving on http://localhoset:3000...");
Iron::new(get_form).http("localhost:3000").unwrap();
}
fnget_form(_request:&mutRequest)->IronResult<Response>{
let mut response=Response::new();
response.set_mut(status::Ok);
response.set_mut(mime!(Text/Html; Charset=Utf8));
response.set_mut(r#"
<title> GCD Calculator</title>
<form action="/gcd" method="post">
<input type="text" name="n"/>
<input type="text" name="n"/>
<button type="submit">compute GCD</button>
</form>
"#);
Ok (response)
}
Hello, it looks like you are referring to the old code example.
mime
macros are available up to mime0.2 series and are not available for your mime0.3.16.Also, since the iron 0.5 series depends on mime 0.2 series, the compilation goes through by rewriting the mime="0.3.16"
part of Cargo.toml with mime="0.2"
.
The above problem will be solved for the time being, but I would like to point out other points.
extern rate
and #[macro_use]
are rarely used.
If you go to the iron and mime repositories, it seems that there are quite a few changes from the latest version that is currently released, so I'll stop posting old codes here again, but if you're interested, please check out how to write new ones.
Since mime
crate obsoleted the mime!
macro in 0.3
, setting the mime
version of Cargo.toml
to 0.2.6
should make the mime!
macro usable
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?
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.