summaryrefslogtreecommitdiffstats
path: root/tests/ui/statics/static-function-pointer.rs
blob: 6c52dfecdec9a7773715fe83bead8b4e66900727 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// run-pass

fn f(x: isize) -> isize { x }
fn g(x: isize) -> isize { 2 * x }

static F: fn(isize) -> isize = f;
static mut G: fn(isize) -> isize = f;

pub fn main() {
    assert_eq!(F(42), 42);
    unsafe {
        assert_eq!(G(42), 42);
        G = g;
        assert_eq!(G(42), 84);
    }
}