货物想通过这最后一条消息告诉我什么?:
error: test failed, to rerun pass '--lib'
即使 Cargo 书中也有测试示例,显示了这确切的最后一行,但没有解释。这听起来几乎像是在说,“如果您不通过 --lib,我们将不会重新运行测试” - 它是否从缓存中提取测试结果?
如果我在命令行中添加“--lib”,即:cargo test --features some_feature --lib,它似乎没有做任何特别的事情。
经过一些挖掘,我发现了一个 Cargo 代码更改,似乎试图显示“{pkg_info}--lib”
那么,Cargo 想告诉我什么?一些有意义的东西,或者只是一个让新用户感到困惑的错误?
代码:
// 非常复杂的 where 子句由多个运行时变量组合而成。
let query: String = String.from("where ..........");
let rows_num: i64 = sqlx::query!( &*query).fetch_one(connection)
Run Code Online (Sandbox Code Playgroud)
编译器的错误:
error: expected string literal
--> src/abc.rs:80:25
|
80 | let rows_num: i64 = sqlx::query!(
| ____________^
81 | | &*query,
82 | | ).fetch_one(connection)
| |^
|
= note: this error originates in the macro sqlx::query (in Nightly builds, run with -Z macro-backtrace for more info)
Run Code Online (Sandbox Code Playgroud)
该文档指出:
查询必须是字符串文字,否则无法内省(因此不能是动态的或另一个宏的结果)。
我知道 sqlx 在编译时计算,我的 where 子句计算在运行时。我真的很想使用变量,因为 where 子句取决于其他几个条件。有什么方法可以在sqlx中使用变量吗?
fuse我在 Rust 生态系统中遇到了这个词:
slog::Fuse将错误推向恐慌。
FutureExt::Fuse“融合一个未来,这样民意调查一旦完成就不会再被召集。”
我知道 Linux 的 FUSE,一个用户空间文件系统。保险丝也是一种电气元件,当流过保险丝的电流过大时,保险丝就会进入开路状态。在硬件中,“熔断”描述了通过(历史上)通过硅的特定导线中的过电流熔断硅中的电路来将配置烘焙到硅中。
Rust 中的“保险丝”通常意味着什么?它的词源是什么?
我正在构建一个 Rust 应用程序,并使用Simple Logger来记录我的应用程序的初始化。我的main.rs看起来像这样:
use log::info;
use simple_logger::SimpleLogger;
fn main() {
SimpleLogger::new().init().unwrap();
let (event_loop, mut interface) = create_interface();
info!("Game interface created");
Run Code Online (Sandbox Code Playgroud)
上面的代码出错了:
thread 'main' panicked at 'Could not determine the UTC offset on this system. Possible causes are that the time crate does not implement "local_offset_at" on your system, or that you are running in a multi-threaded environment and the time crate is returning "None" from "local_offset_at" to avoid unsafe behaviour. See the time crate's documentation …Run Code Online (Sandbox Code Playgroud) 通过运行ffmpeg -h encoder=apng,我得到了这个:
APNG encoder AVOptions:
-dpi <int> E..V..... Set image resolution (in dots per inch) (from 0 to 65536) (default 0)
-dpm <int> E..V..... Set image resolution (in dots per meter) (from 0 to 65536) (default 0)
-pred <int> E..V..... Prediction method (from 0 to 5) (default none)
none E..V.....
sub E..V.....
up E..V.....
avg E..V.....
paeth E..V.....
mixed E..V.....
Run Code Online (Sandbox Code Playgroud)
这些用 指定的预测方法有什么区别-pred?
我在 ffmpeg.org 或其他地方找不到任何文档。
serde::Deserialize我正在尝试在一个结构体上实现SourceConfig,该结构体包装了一个包含 的结构体&'static str以及它自己的一些数据(游乐场):
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct Config {
pub name: &'static str,
}
#[derive(Serialize, Deserialize)]
struct SourceConfig {
config: Config,
id: u32,
}
Run Code Online (Sandbox Code Playgroud)
但这给了我一个终生错误:
Compiling playground v0.0.1 (/playground)
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'de` due to conflicting requirements
--> src/lib.rs:10:5
|
10 | config: Config,
| ^^^^^^
|
note: first, the lifetime cannot outlive the lifetime `'de` as defined on the impl at 8:21...
--> …Run Code Online (Sandbox Code Playgroud) 我有两种 Rust 方法,根据两个不同的参数从同一个 SQLite 表中使用 sqlx 选择数据。
由于错误,我无法让两者都工作expected `i64`, found enum `std::option::Option` 。
代码
// src/main.rs
use tokio;
use anyhow::Result;
use sqlx::sqlite::SqlitePool;
// The model `StorageName` that I'm retrieving is something like
pub struct StorageName {
pub _id: i64,
pub name: String,
pub url: String,
}
// This compiles only if `_id` is `Option<i64>`
async fn queryByName(pool: &SqlitePool, name: String) -> Result<Vec<StorageName>> {
let results = sqlx::query_as!(
StorageName,
"SELECT * FROM names
WHERE name = ?;",
name,
)
.fetch_all(pool) …Run Code Online (Sandbox Code Playgroud) 我现在有以下服务器声明
let server = HttpServer::new(move || {
App::new()
.app_data(actix_web::web::Data::new(pool.clone()))
.service(ping)
.service(stock::controller::get_all)
.service(stock::controller::find_one)
.service(stock::controller::insert_one)
.service(stock::controller::insert_many)
})
.bind(("127.0.0.1", 7777))?
.run();
Run Code Online (Sandbox Code Playgroud)
我觉得当我添加其他路线时,它会很难控制。有没有办法把它分开,这样我就可以得到类似的东西
App::new()
.app_data(actix_web::web::Data::new(pool.clone()))
.service(ping)
.service(stock::controller::routes)
Run Code Online (Sandbox Code Playgroud)
路由函数是否添加了第一个代码示例中声明的所有服务?
我想为 TopLevel 设置标题,但 TopLevel 显示 Root 的标题。我认为我的下一个脚本与 TkInter 文档中的示例相对应,但给了我不好的结果。你能解释一下,为什么我在AppTop 类中设置master.title = 'Top'没有为 TopLevel 设置新标题?
import tkinter as tk
class AppTop(tk.Frame):
def __init__(self, master):
mon_h = 900
mon_w = 1250
master.title = 'Top'
tk.Frame.__init__(self, master)
master.minsize(height = 900, width = 600)
fr_button = tk.Frame(master)
fr_button.place(relx=0.01, rely=0.06)
butArrowPlus = tk.Button(fr_button, text=">", height = 1, width = 20, command=self.Cmd)
butArrowPlus.grid(column= 1, row= 1)
return
def Cmd(self):
return
class Application(tk.Frame):
def __init__(self, master):
tk.Frame.__init__(self, master)
frRoot = tk.Frame(master, width=700, height=400, bd=2) …Run Code Online (Sandbox Code Playgroud) rust ×7
rust-sqlx ×2
actix-web ×1
apng ×1
ffmpeg ×1
logging ×1
png ×1
postgresql ×1
python ×1
rust-cargo ×1
serde ×1
string ×1
terminology ×1
tkinter ×1
toplevel ×1