Skip to content

Instantly share code, notes, and snippets.

View graysonarts's full-sized avatar
🍑
language hunting

Grayson graysonarts

🍑
language hunting
View GitHub Profile
@graysonarts
graysonarts / string_value_type_macro.rs
Last active November 21, 2023 18:21
Helpful Macros for common rust things I run into
macro_rules! string_value_type {
($TypeName:ident $(~$derive_name:ident)*) => {
#[derive($($derive_name),*)]
pub struct $TypeName(String);
impl From<&str> for $TypeName {
fn from(value: &str) -> Self {
Self(value.to_owned())
}
}