If you have some conditions like this in the Rust language, you can simply use the matches!() macro:
let is_async = matches!(
name,
"sleep" | "array::all" | "array::any" | "array::every"
| "array::filter_index" | "array::filter" | "array::find_index"
| "array::find" | "array::fold" | "array::includes"
| "array::index_of" | "array::map" | "array::reduce" | "array::some"
| "file::put" | "file::put_if_not_exists" | "file::get" | "file::head"
| "file::delete" | "file::exists" | "file::copy" | "file::copy_if_not_exists"
| "file::rename" | "file::rename_if_not_exists" | "file::list"
| "record::exists" | "record::is_edge" | "set::all" | "set::any"
| "set::filter" | "set::find" | "set::fold" | "set::map" | "set::reduce"
| "type::field" | "type::fields" | "value::diff" | "value::expect"
| "value::patch" | "sequence::nextval" | "schema::table::exists"
);
Bye, I'll see you for the next short clean code article😁
Top comments (0)