Skip to content

Commit 862cfd6

Browse files
committed
feat: resolve-core
1 parent 3a99ecb commit 862cfd6

File tree

9 files changed

+30
-19
lines changed

9 files changed

+30
-19
lines changed

Cargo.lock

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["dir-structure", "dir-structure-macros", "dir-structure-tools"]
2+
members = ["dir-structure", "dir-structure-macros", "dir-structure-resolve-core", "dir-structure-tools"]
33
resolver = "2"
44

55
[workspace.package]
@@ -17,6 +17,7 @@ assert_eq_macros = { version = "=0.2.0" }
1717
assert_eq = { version = "0.2.0" }
1818
dir-structure-macros = { path = "dir-structure-macros", version = "=0.2.0", default-features = false }
1919
dir-structure-tools = { path = "dir-structure-tools", version = "=0.2.0", default-features = false }
20+
dir-structure-resolve-core = { path = "dir-structure-resolve-core", version = "=0.2.0", default-features = false }
2021
dir-structure = { path = "dir-structure", version = "=0.2.0", default-features = false }
2122

2223
bumpalo = "3.6.0"

dir-structure-macros/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ proc-macro = true
1313

1414
[features]
1515
async = []
16-
resolve-path = []
17-
include_dir_vfs = ["dep:include_dir_macros"]
16+
resolve-path = ["dep:dir-structure-resolve-core"]
17+
include_dir_vfs = []
1818

1919
[dependencies]
2020
quote.workspace = true
2121
syn.workspace = true
2222
proc-macro2.workspace = true
23-
include_dir_macros = { package = "include_dir_macros", version = "0.7", optional = true }
23+
dir-structure-resolve-core = { workspace = true, optional = true }
2424

2525
[lints]
2626
workspace = true

dir-structure-macros/src/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,6 @@ pub fn load_path(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
5858
resolve_path::load_path(input)
5959
}
6060

61-
#[cfg(feature = "resolve-path")]
62-
#[proc_macro]
63-
pub fn __resolve_max_len(_input: proc_macro::TokenStream) -> proc_macro::TokenStream {
64-
// This macro is used to get the maximum length of a field name for the `HasField` trait.
65-
// It is used in the `resolve_path` macro to ensure that field names do not exceed this length.
66-
let max_len = resolve_path::MAX_LEN;
67-
let output = quote::quote! { #max_len };
68-
output.into()
69-
}
70-
7161
#[cfg(feature = "include_dir_vfs")]
7262
#[proc_macro]
7363
pub fn include_dir_patched(input: proc_macro::TokenStream) -> proc_macro::TokenStream {

dir-structure-macros/src/resolve_path.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::iter;
22

3+
use dir_structure_resolve_core::MAX_LEN;
34
use proc_macro2::TokenStream;
45
use quote::format_ident;
56
use quote::quote;
@@ -24,8 +25,6 @@ use crate::dir_structure_core::compile_attrs;
2425
// or
2526
// resolve_path!(["path/to/dir" as T].a."b".c.d.${e});
2627

27-
pub const MAX_LEN: usize = 32;
28-
2928
struct CoreTyExpression {
3029
path: syn::Expr,
3130
ty: syn::Type,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "dir-structure-resolve-core"
3+
version.workspace = true
4+
edition.workspace = true
5+
homepage.workspace = true
6+
repository.workspace = true
7+
description.workspace = true
8+
keywords.workspace = true
9+
license.workspace = true
10+
11+
[dependencies]
12+
13+
[lints]
14+
workspace = true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub const MAX_LEN: usize = 32;

dir-structure/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ include_dir = [
2121
"dir-structure-macros/include_dir_vfs", # need workaround until https://github.com/Michael-F-Bryan/include_dir/pull/115 for the include_dir_vfs! macro
2222
]
2323
git = ["dep:git2"]
24-
resolve-path = ["derive", "dir-structure-macros/resolve-path"]
24+
resolve-path = ["derive", "dir-structure-macros/resolve-path", "dep:dir-structure-resolve-core"]
2525
assert_eq = ["dep:assert_eq"]
2626
derive = ["dep:dir-structure-macros"]
2727

@@ -40,6 +40,7 @@ tokio = { version = "1", features = ["full"] }
4040

4141
[dependencies]
4242
dir-structure-macros = { workspace = true, optional = true }
43+
dir-structure-resolve-core = { workspace = true, optional = true }
4344
futures = { version = "0.3", optional = true, default-features = false, features = [
4445
"io-compat",
4546
] }

dir-structure/src/traits/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use crate::traits::vfs::OwnedPathType;
77

88
#[doc(hidden)]
9-
pub const HAS_FIELD_MAX_LEN: usize = dir_structure_macros::__resolve_max_len!();
9+
pub const HAS_FIELD_MAX_LEN: usize = dir_structure_resolve_core::MAX_LEN;
1010

1111
/// A trait to declare that a type has a field with a specific name,
1212
/// and the type of the field is [`HasField::Inner`].

0 commit comments

Comments
 (0)