我的文件结构如下:
├── Cargo.lock
├── Cargo.toml
├── diesel.toml
├── migrations
│ └── 2024-11-14-193305_create_entities
│ ├── down.sql
│ └── up.sql
└── src
└── main.rs
在我的
main.rs
我有:
use diesel_migrations::embed_migrations;
embed_migrations!("migrations");
但是它给了我一个错误:
error: expected one of `!` or `::`, found `(`
--> src/main.rs:13:1
|
13 | embed_migrations!("migrations");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected one of `!` or `::`
|
= note: this error originates in the macro `embed_migrations` (in Nightly builds, run with -Z macro-backtrace for more info)
知道我该如何继续吗?
对于未来的某个人, 正如 @kmdreko 指出的,我使用的是
diesel_migration=="2.2.0"
,但使用的是旧语法。我当前的语法工作正常,如下:
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");