mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-21 02:23:19 +00:00
28 lines
498 B
Rust
28 lines
498 B
Rust
|
fn fn_pointer_static() -> usize {
|
||
|
static FN: fn() -> usize = || 1;
|
||
|
let res = FN() + 1;
|
||
|
res
|
||
|
}
|
||
|
|
||
|
fn fn_pointer_const() -> usize {
|
||
|
const FN: fn() -> usize = || 1;
|
||
|
let res = FN() + 1;
|
||
|
res
|
||
|
}
|
||
|
|
||
|
fn deref_to_dyn_fn() -> usize {
|
||
|
struct Derefs;
|
||
|
impl std::ops::Deref for Derefs {
|
||
|
type Target = dyn Fn() -> usize;
|
||
|
|
||
|
fn deref(&self) -> &Self::Target {
|
||
|
&|| 2
|
||
|
}
|
||
|
}
|
||
|
static FN: Derefs = Derefs;
|
||
|
let res = FN() + 1;
|
||
|
res
|
||
|
}
|
||
|
|
||
|
fn main() {}
|