Hi folks,
I actually have a quite "interesting" problem.
Start with this piece of code:
#[cfg(feature = "pro")]
let write_aof = Some(WriteAOF);
#[cfg(not(feature = "pro"))]
let write_aof = None;
let mut types = r::ffi::RedisModuleTypeMethods {
version: 1,
rdb_load: Some(rdb_load),
rdb_save: Some(rdb_save),
aof_rewrite: write_aof,
mem_usage: None,
digest: None,
free: Some(free_db),
};
where the idea is to include or not include a particular function write_aof
if a features is on or off.
This code does not compile and provide this error.
error[E0308]: mismatched types
--> src/lib.rs:698:22
|
698 | aof_rewrite: write_aof,
| ^^^^^^^^^ expected fn pointer, found fn item
|
= note: expected type `std::option::Option<unsafe extern "C" fn(*mut redisql_lib::redis::ffi::RedisModuleIO, *mut redisql_lib::redis::ffi::RedisModuleString, *mut std::os::raw::c_void)>`
found type `std::option::Option<unsafe extern "C" fn(*mut redisql_lib::redis::ffi::RedisModuleIO, *mut redisql_lib::redis::ffi::RedisModuleString, *mut std::os::raw::c_void) {engine_pro::WriteAOF}>`
= help: here are some functions which might fulfill your needs:
Which already is not very clear and I am not quite sure what I am doing wrong.
But what I believe is even more interesting is the fact that this other code does compile perfectly.
#[cfg(feature = "pro")]
let mut types = r::ffi::RedisModuleTypeMethods {
version: 1,
rdb_load: Some(rdb_load),
rdb_save: Some(rdb_save),
aof_rewrite: WriteAOF,
mem_usage: None,
digest: None,
free: Some(free_db),
};
#[cfg(not(feature = "pro"))]
let mut types = r::ffi::RedisModuleTypeMethods {
version: 1,
rdb_load: Some(rdb_load),
rdb_save: Some(rdb_save),
aof_rewrite: None,
mem_usage: None,
digest: None,
free: Some(free_db),
};
It is juts me doing something very stupid and not seeingg it, or I should fill some bug report?