$ rustc --version
rustc 1.59.0-nightly (db9d361a4 2021-11-28)
$ rustup default stable
$ rustc --version
rustc 1.56.1 (59eed8a2a 2021-11-01)
$ sudo apt install gcc-mingw-w64-x86-64
$ rustup target add x86_64-pc-windows-gnu
$ rustup toolchain install stable-x86_64-pc-windows-gnu
// src/main.rs
use actix_web::{get, App, HttpResponse, HttpServer, Responder};
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(hello)
})
.bind("127.0.0.1:18000")?
.run()
.await
}
$ cargo build --target x86_64-pc-windows-gnu --release
C:\test>bin\curl.exe -i -XGET http://127.0.0.1:18000
HTTP/1.1 200 OK
content-length: 12
date: Mon, 29 Nov 2021 13:17:58 GMT
Hello world!