< 返回版块

jojo 发表于 2023-08-09 23:41

油管视频跟着做,3分57那会:先 watch server,后test httpc_test直接文件无法打开冲突了

Cargo.toml

[package]
name = "intro"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1.29.1", features = ["full"] }
axum = "0.6"

[dev-dependencies]
anyhow = "1"
httpc-test = "0.1.1"

/src/main.rs

use std::net::SocketAddr;

use axum::{Router, routing::get, response::Html};

#[tokio::main]
async fn main() {
    let routes_hello = Router::new().route(
        "/hello",
        get(|| async { Html("Hello <strong>World!!!</strong>") })
    );

    let addr = SocketAddr::from(([127, 0, 0, 1], 8080));
    println!("->> LISTENING on {}\n", addr);

    axum::Server::bind(&addr)
        .serve(routes_hello.into_make_service())
        .await
        .unwrap();
}

cargo watch -q -c -w .\src\ -x run
/tests/quick_dev.rs

#[allow(unused)]

use anyhow::Result;

#[tokio::test]
async fn quick_dev() -> Result<()> {
    let hc = httpc_test::new_client("http://localhost:8080")?;

    hc.do_get("/hello").await?.print().await?;

    Ok(())
}
cargo test -q quick_dev -- --nocapture
note: LINK : fatal error LNK1104: 无法打开文件“C:\Users\jojo\Desktop\Axum_Full_Course\intro\target\debug\deps\intro.exe”

评论区

写评论
作者 jojo 2023-08-10 14:42

原来如此,十分感谢😁

--
👇
Pikachu: https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk1104?view=msvc-170

Windows系统的限制。当一个程序正在跑的时候你无法修改该文件。

Pikachu 2023-08-10 13:25

https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk1104?view=msvc-170

Windows系统的限制。当一个程序正在跑的时候你无法修改该文件。

1 共 2 条评论, 1 页