feat: Added more Typed impls

This commit is contained in:
2025-09-20 05:28:46 +02:00
parent 21bc70cbcd
commit fe958b863a
3 changed files with 76 additions and 1 deletions

49
Cargo.lock generated
View File

@@ -2,6 +2,15 @@
# It is not intended for manual editing.
version = 4
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "console"
version = "0.15.11"
@@ -47,6 +56,16 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "eui48"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "887418ac5e8d57c2e66e04bdc2fe15f9a5407be20b54a82c86bd0e368b709701"
dependencies = [
"regex",
"serde",
]
[[package]]
name = "glob"
version = "0.3.3"
@@ -105,6 +124,7 @@ checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
name = "lua_typed"
version = "0.1.0"
dependencies = [
"eui48",
"insta",
"lua_typed_macro",
"trybuild",
@@ -151,6 +171,35 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001"
[[package]]
name = "ryu"
version = "1.0.20"

View File

@@ -7,6 +7,7 @@ edition = "2024"
members = ["lua_typed_macro"]
[dependencies]
eui48 = { version = "1.1.0", features = ["serde"], default-features = false }
lua_typed_macro = { path = "./lua_typed_macro/" }
[dev-dependencies]

View File

@@ -1,5 +1,10 @@
#![feature(negative_impls)]
use eui48::MacAddress;
pub use lua_typed_macro::Typed;
use std::collections::HashMap;
use std::{
collections::HashMap,
net::{Ipv4Addr, SocketAddr},
};
pub trait Typed {
fn type_name() -> String;
@@ -132,6 +137,26 @@ impl Typed for String {
}
}
impl Typed for SocketAddr {
fn type_name() -> String {
"string".into()
}
}
impl Typed for Ipv4Addr {
fn type_name() -> String {
"string".into()
}
}
impl Typed for MacAddress {
fn type_name() -> String {
"string".into()
}
}
impl<A: Typed, B: Typed> !Typed for (A, B) {}
impl<T: Typed> Typed for Option<T> {
fn type_name() -> String {
format!("{}?", <T as Typed>::type_name())