Crate vec_const[][src]

Expand description

vec-const

This crate used to break some rules to give you a Vec declared as const. This was unnecessary, as std::borrow::Cow is capable of providing equivalent functionality in a safe way with a usable API. The latest version of this crate just wraps input in a Cow::Borrowed([T]). You don’t need to use this crate at all, just do it yourself!

use vec_const::vec_const;
use std::borrow::Cow;

#[derive(PartialEq, Clone, Debug, Default)]
pub struct AThing(u8, &'static str);

const A_VEC_CONST: Cow<'static, [AThing]> = vec_const!(AThing(5, "alright"), AThing(2, "fine"));

fn main()
{
    assert_eq!(*A_VEC_CONST, vec!(AThing(5, "alright"), AThing(2, "fine")));
}

Macros

Wraps content in a Cow::Borrowed(...)