Closed 3517277 closed 1 day ago
#[salvo::oapi::endpoint]
async fn test3() -> std::result::Result<(), impl salvo::Writer> {
if false {
Ok(async move {
{
println!("222");
};
}.await)
} else {
Err(salvo::prelude::StatusCode::FORBIDDEN)
}
}
其实,这样就行了,其它代码多余的
看了一下,应该是这句话引起的:
<std::result::Result<(), impl salvo::Writer> as salvo::oapi::EndpointOutRegister>::register(
components, operation,
)
似乎 Rust 现在不允许这么表示。
看了一下,应该是这句话引起的:
<std::result::Result<(), impl salvo::Writer> as salvo::oapi::EndpointOutRegister>::register( components, operation, )
似乎 Rust 现在不允许这么表示。
提示确实说只能用于方法返回,看来只能放弃使用impl trait了
rust version:1.81 salvo verion:1.72
,这里会直接报错 'impl Trait
is not allowed in paths [E0562] Note:
impl Trait` is only allowed in arguments and return types of functions and methods。 查看代码,好像endpoint宏展开时把方法作为参数传递出现的问题?