aboutsummaryrefslogtreecommitdiff
path: root/syn-mid/examples/const_fn_test/tests/test.rs
blob: 1b2c7420fc993fe74430c29f1a2f1606eec25d6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#![cfg_attr(nightly, feature(const_fn, const_vec_new))]
#![warn(rust_2018_idioms)]
#![allow(dead_code)]

use const_fn::const_fn;

#[const_fn(nightly)]
fn const_vec_new<T>() -> Vec<T> {
    let vec = Vec::new();
    vec
}

#[test]
fn test_stable() {
    assert_eq!(const_vec_new::<u8>(), Vec::new());
}

#[cfg(nightly)]
const CONST_UNSTABLE: Vec<u8> = const_vec_new();

#[cfg(nightly)]
#[test]
fn test_unstable() {
    assert_eq!(CONST_UNSTABLE, Vec::new());
}