how to let the rust code using local use command
I have a write a rust code look like this:
fn find_channel(request: &ChannelRequest) -> Box<dyn BoxableExpression<crate::model::diesel::dolphin::dolphin_schema::rss_sub_source::table, DB, SqlType=Bool> + '_> {
use crate::model::diesel::dolphin::dolphin_schema::rss_sub_source::dsl::*;
match request {
ChannelRequest { editorPick, .. } if editorPick.unwrap_or(0) == 1 => Box::new(crate::model::diesel::dolphin::dolphin_schema::rss_sub_source::dsl::editor_pick.eq(editorPick)),
ChannelRequest{ minimalReputation, ..} if minimalReputation.unwrap_or(0) > 0 => Box::new(crate::model::diesel::dolphin::dolphin_schema::rss_sub_source::dsl::reputation.gt(minimalReputation)),
_ => Box::new(crate::model::diesel::dolphin::dolphin_schema::rss_sub_source::dsl::editor_pick.eq(0))
}
}
Now I want to make the code more shorter, and remove crate::model::diesel::dolphin::dolphin_schema::rss_sub_source::dsl::
and want to let the editor_pick
to use local function import command. To my surprise, the IDE still tell me to import the crate::model::diesel::dolphin::dolphin_schema::rss_sub_source::dsl::
, why still need import even through imported in the function? what should I to to remove the package path from the code and make the code more shorter and cleaner? is it possible to remove the package path from code? This is the intellij tips from IDE:
Solution 1:
Does cargo
/rustc
accept the code? It's possible that IntelliJ Rust is buggy in this case.