Nlopt::srand_seed cannot be directly invoked, because of the requirements of Nlopt
1168 | Nlopt::srand_seed(Some(10));
| ^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `F` declared on the struct `Nlopt`
If we try to name the objective fn:
error[E0747]: constant provided when a type was expected
--> src/lib.rs:1168:17
|
1168 | Nlopt::<fake_objfn, ()>::srand_seed(Some(10));
| ^^^^^^^^^^
|
= help: `fake_objfn` is a function item, not a type
= help: function item types cannot be named directly
A hack that does work:
fn fake_objfn(_: &[f64], _: Option<&mut [f64]>, _: &mut ()) -> f64 {
unreachable!()
}
fn set_seed<F: ObjFn<()>>(_: F) {
Nlopt::<F, ()>::srand_seed(Some(10));
}
set_seed(fake_objfn);
Yuck! It should probably just be a global function (not tied to the Nlopt object), like in the C lib.
Nlopt::srand_seedcannot be directly invoked, because of the requirements ofNloptIf we try to name the objective fn:
A hack that does work:
Yuck! It should probably just be a global function (not tied to the Nlopt object), like in the C lib.