不能将一元运算符 `!` 应用于 Diesel
Cannot apply unary operator `!` with Diesel
我正在使用 !
做这样的不等于:
ChannelRequest { excludeEditorPickChannel, ..} if excludeEditorPickChannel.unwrap_or(0) == 1 => Box::new(!editor_pick.eq(excludeEditorPickChannel)),
当我编译这段代码时它显示错误:
error[E0600]: cannot apply unary operator `!` to type `diesel::expression::operators::Eq<dolphin_schema::rss_sub_source::columns::editor_pick, diesel::expression::bound::Bound<diesel::sql_types::Nullable<Integer>, &std::option::Option<i32>>>`
--> src/service/app/cruise/channel/channel_service.rs:35:114
|
35 | ...unwrap_or(0) == 1 => Box::new(!editor_pick.eq(excludeEditorPickChannel)),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot apply unary operator `!`
For more information about this error, try `rustc --explain E0600`.
warning: `reddwarf-admin` (bin "reddwarf-admin") generated 10 warnings
error: could not compile `reddwarf-admin` due to previous error; 10 warnings emitted
editor_pick
是柴油 table 架构列。 table 定义如下:
table! {
rss_sub_source (id) {
id -> Int8,
sub_url -> Varchar,
created_time -> Int8,
updated_time -> Int8,
sub_status -> Int2,
rss_type -> Varchar,
standard_type -> Varchar,
standard_version -> Varchar,
cron -> Varchar,
trigger_count -> Int4,
next_trigger_time -> Nullable<Timestamp>,
sub_name -> Varchar,
last_trigger_time -> Nullable<Timestamptz>,
tags -> Nullable<Array<Int4>>,
source_url -> Nullable<Varchar>,
sub_type -> Nullable<Varchar>,
intro -> Nullable<Varchar>,
remark -> Nullable<Varchar>,
title_hash -> Nullable<Varchar>,
failed_count -> Int4,
lang -> Nullable<Varchar>,
frequency_month -> Nullable<Int4>,
reputation -> Nullable<Int4>,
rep_lastest_refresh_time -> Nullable<Int8>,
scrapy_take_time -> Nullable<Int4>,
follower -> Nullable<Int8>,
censor_status -> Nullable<Int4>,
etag -> Nullable<Varchar>,
last_modified -> Nullable<Varchar>,
editor_pick -> Nullable<Int4>,
fav_icon_url -> Nullable<Varchar>,
dynamic_interval -> Int4,
local_icon_url -> Nullable<Varchar>,
creator -> Int8,
}
}
excludeEditorPickChannel
是rust火箭接收到的参数,excludeEditorPickChannel
定义如下:
#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
#[allow(non_snake_case)]
pub struct ChannelRequest {
pub userId: Option<i64>,
pub pageNum: Option<i64>,
pub pageSize: Option<i64>,
pub editorPick: Option<i32>,
pub minimalReputation: Option<i32>,
pub excludeEditorPickChannel: Option<i32>
}
为什么我不能应用!
?我应该怎么做才能实现不等于?
您可以使用 ne
代替 !eq
。
我正在使用 !
做这样的不等于:
ChannelRequest { excludeEditorPickChannel, ..} if excludeEditorPickChannel.unwrap_or(0) == 1 => Box::new(!editor_pick.eq(excludeEditorPickChannel)),
当我编译这段代码时它显示错误:
error[E0600]: cannot apply unary operator `!` to type `diesel::expression::operators::Eq<dolphin_schema::rss_sub_source::columns::editor_pick, diesel::expression::bound::Bound<diesel::sql_types::Nullable<Integer>, &std::option::Option<i32>>>`
--> src/service/app/cruise/channel/channel_service.rs:35:114
|
35 | ...unwrap_or(0) == 1 => Box::new(!editor_pick.eq(excludeEditorPickChannel)),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot apply unary operator `!`
For more information about this error, try `rustc --explain E0600`.
warning: `reddwarf-admin` (bin "reddwarf-admin") generated 10 warnings
error: could not compile `reddwarf-admin` due to previous error; 10 warnings emitted
editor_pick
是柴油 table 架构列。 table 定义如下:
table! {
rss_sub_source (id) {
id -> Int8,
sub_url -> Varchar,
created_time -> Int8,
updated_time -> Int8,
sub_status -> Int2,
rss_type -> Varchar,
standard_type -> Varchar,
standard_version -> Varchar,
cron -> Varchar,
trigger_count -> Int4,
next_trigger_time -> Nullable<Timestamp>,
sub_name -> Varchar,
last_trigger_time -> Nullable<Timestamptz>,
tags -> Nullable<Array<Int4>>,
source_url -> Nullable<Varchar>,
sub_type -> Nullable<Varchar>,
intro -> Nullable<Varchar>,
remark -> Nullable<Varchar>,
title_hash -> Nullable<Varchar>,
failed_count -> Int4,
lang -> Nullable<Varchar>,
frequency_month -> Nullable<Int4>,
reputation -> Nullable<Int4>,
rep_lastest_refresh_time -> Nullable<Int8>,
scrapy_take_time -> Nullable<Int4>,
follower -> Nullable<Int8>,
censor_status -> Nullable<Int4>,
etag -> Nullable<Varchar>,
last_modified -> Nullable<Varchar>,
editor_pick -> Nullable<Int4>,
fav_icon_url -> Nullable<Varchar>,
dynamic_interval -> Int4,
local_icon_url -> Nullable<Varchar>,
creator -> Int8,
}
}
excludeEditorPickChannel
是rust火箭接收到的参数,excludeEditorPickChannel
定义如下:
#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
#[allow(non_snake_case)]
pub struct ChannelRequest {
pub userId: Option<i64>,
pub pageNum: Option<i64>,
pub pageSize: Option<i64>,
pub editorPick: Option<i32>,
pub minimalReputation: Option<i32>,
pub excludeEditorPickChannel: Option<i32>
}
为什么我不能应用!
?我应该怎么做才能实现不等于?
您可以使用 ne
代替 !eq
。