use batch_impl::batch_impl;
use batch_impl::batch_trait;
fn test_boundary_cases() {
#[batch_impl(Box^[Box^isize])]
trait S1a {}
fn _1a<T: S1a>() {}
_1a::<Box<[Box<isize>]>>();
println!(" 1a. Box^[Box^isize] = Box<[Box<isize>]>: OK");
#[batch_impl([Box, Vec]^[&^u32, u64])]
trait S1b {}
fn _1b<T: S1b>() {}
_1b::<Box<&u32>>();
_1b::<Box<u64>>();
_1b::<Vec<&u32>>();
_1b::<Vec<u64>>();
println!(" 1b. [Box,Vec]^[&^u32, u64] = 4 impls: OK");
}
fn test_caret_nesting() {
#[batch_impl(Box^Box^Box^u32)]
trait S2a {}
fn _2a<T: S2a>() {}
_2a::<Box<Box<Box<u32>>>>();
println!(" 2a. Box^Box^Box^u32: OK");
#[batch_impl([Box, Vec]^[u32, i64])]
trait S2b {}
fn _2b<T: S2b>() {}
_2b::<Box<u32>>();
_2b::<Box<i64>>();
_2b::<Vec<u32>>();
_2b::<Vec<i64>>();
println!(" 2b. [Box,Vec]^[u32,i64] = 4 impls: OK");
#[batch_impl([&, self]^[u32, i64])]
trait S2c {}
fn _2c<T: S2c>() {}
_2c::<&u32>();
_2c::<&i64>();
_2c::<u32>();
_2c::<i64>();
println!(" 2c. [&,self]^[u32,i64] = 4 impls: OK");
#[batch_impl(HashMap^<u32, String>)]
trait S2d {}
fn _2d<T: S2d>() {}
_2d::<HashMap<u32, String>>();
println!(" 2d. HashMap^<u32,String>: OK");
#[batch_impl(Vec^[u32, i64])]
trait S2e {}
fn _2e<T: S2e>() {}
_2e::<Vec<u32>>();
_2e::<Vec<i64>>();
println!(" 2e. Vec^[u32,i64] = 2 impls: OK");
}
fn test_cartesian() {
#[batch_impl((u32, i32)^3)]
trait S3a {}
fn _3a<T: S3a>() {}
_3a::<(u32, u32, u32)>();
_3a::<(u32, u32, i32)>();
_3a::<(u32, i32, u32)>();
_3a::<(u32, i32, i32)>();
_3a::<(i32, u32, u32)>();
_3a::<(i32, u32, i32)>();
_3a::<(i32, i32, u32)>();
_3a::<(i32, i32, i32)>();
println!(" 3a. (u32,i32)^3 = 8 impls: OK");
#[batch_impl((u32,)^3)]
trait S3b {}
fn _3b<T: S3b>() {}
_3b::<(u32, u32, u32)>();
println!(" 3b. (u32,)^3 = (u32,u32,u32): OK");
#[batch_impl(()^3)]
trait S3c {}
fn _3c<T: S3c>() {}
_3c::<(i32, i32, i32)>();
println!(" 3c. ()^3 = (A,B,C): OK");
}
fn test_append_tuple() {
#[batch_impl(()^u32)]
trait S4a {}
fn _4a<T: S4a>() {}
_4a::<(u32,)>();
println!(" 4a. ()^u32 = (u32,): OK");
#[batch_impl((i32,)^u32)]
trait S4b {}
fn _4b<T: S4b>() {}
_4b::<(i32, u32)>();
println!(" 4b. (i32,)^u32 = (i32,u32): OK");
#[batch_impl(()^Box^u32)]
trait S4c {}
fn _4c<T: S4c>() {}
_4c::<(Box<u32>,)>();
println!(" 4c. ()^Box^u32 = (Box<u32>,): OK");
}
fn test_dash() {
#[batch_impl(()-[usize, isize]-[u32, i32])]
trait S5a {}
fn _5a<T: S5a>() {}
_5a::<(usize, u32)>();
_5a::<(usize, i32)>();
_5a::<(isize, u32)>();
_5a::<(isize, i32)>();
println!(" 5a. ()-[usize,isize]-[u32,i32] = 4 impls: OK");
#[batch_impl(()-[Box^u32, Vec^isize]-[i64, i32])]
trait S5b {}
fn _5b<T: S5b>() {}
_5b::<(Box<u32>, i64)>();
_5b::<(Box<u32>, i32)>();
_5b::<(Vec<isize>, i64)>();
_5b::<(Vec<isize>, i32)>();
println!(" 5b. ()-[Box^u32,Vec^isize]-[i64,i32] = 4 impls: OK");
}
fn test_operator_precedence() {
#[batch_impl(Box^Vec^u32)]
trait S6a {}
fn _6a<T: S6a>() {}
_6a::<Box<Vec<u32>>>();
println!(" 6a. Box^Vec^u32 = Box<Vec<u32>>: OK");
#[batch_impl(HashMap-u32-String)]
trait S6b {}
fn _6b<T: S6b>() {}
_6b::<HashMap<u32, String>>();
println!(" 6b. HashMap-u32-String = HashMap<u32,String>: OK");
println!(" 6c. ^- semantic difference verified: OK");
}
fn test_self_identity() {
#[batch_impl(self^self^u32)]
trait S7a {}
fn _7a<T: S7a>() {}
_7a::<u32>();
println!(" 7a. self^self^u32 = u32: OK");
#[batch_impl([self, &]^u32)]
trait S7b {}
fn _7b<T: S7b>() {}
_7b::<u32>();
_7b::<&u32>();
println!(" 7b. [self,&]^u32 = u32, &u32: OK");
#[batch_impl([self, &mut]^i64)]
trait S7c {}
fn _7c<T: S7c>() {}
_7c::<i64>();
_7c::<&mut i64>();
println!(" 7c. [self,&mut]^i64 = i64, &mut i64: OK");
}
fn test_pointer_chain() {
#[batch_impl(*const^Box^u32)]
trait S8a {}
fn _8a<T: S8a>() {}
_8a::<*const Box<u32>>();
println!(" 8a. *const^Box^u32 = *const Box<u32>: OK");
#[batch_impl(*mut^Vec^i64)]
trait S8b {}
fn _8b<T: S8b>() {}
_8b::<*mut Vec<i64>>();
println!(" 8b. *mut^Vec^i64 = *mut Vec<i64>: OK");
#[batch_impl([&, *const]^Box^u32)]
trait S8c {}
fn _8c<T: S8c>() {}
_8c::<&Box<u32>>();
_8c::<*const Box<u32>>();
println!(" 8c. [&, *const]^Box^u32 = &Box<*>, *const Box<*>");
}
fn test_unsafe_double() {
#[batch_impl(usize, Box<u32>)]
unsafe trait S9a {}
fn _9a<T: S9a>() {}
_9a::<usize>();
_9a::<Box<u32>>();
println!(" 9a. unsafe trait auto-detect for all impls: OK");
#[batch_impl(unsafe^usize, isize)]
unsafe trait S9b {}
fn _9b<T: S9b>() {}
_9b::<usize>();
_9b::<isize>();
println!(" 9b. unsafe^usize + non-unsafe isize: OK");
}
fn test_fn_caret_vs_dash() {
#[batch_impl(fn^(u32,i32)-usize)]
trait S10a {}
fn _10a<T: S10a>() {}
_10a::<fn(u32, i32) -> usize>();
println!(" 10a. fn^(u32,i32)-usize = fn(u32,i32)->usize: OK");
#[batch_impl(fn(u32,i32)-usize)]
trait S10b {}
fn _10b<T: S10b>() {}
_10b::<fn(u32, i32) -> usize>();
println!(" 10b. fn(u32,i32)-usize = fn(u32,i32)->usize: OK");
println!(" 10c. fn^(...)-usize and fn(...)-usize both produce fn(...)->usize: OK");
#[batch_impl(fn^(u32,i32)-[usize, isize])]
trait S10d {}
fn _10d<T: S10d>() {}
_10d::<fn(u32, i32) -> usize>();
_10d::<fn(u32, i32) -> isize>();
println!(" 10d. fn^(u32,i32)-[usize,isize] = 2 fn types: OK");
#[batch_impl(fn^(u32,i32)^i64-usize)]
trait S10e {}
fn _10e<T: S10e>() {}
_10e::<fn(u32, i32, i64) -> usize>();
println!(" 10e. fn^(u32,i32)^i64-usize = fn(u32,i32,i64)->usize: OK");
#[batch_impl(fn^(u32,i32)-Box^u32)]
trait S10f {}
fn _10f<T: S10f>() {}
_10f::<fn(u32, i32) -> Box<u32>>();
println!(" 10f. fn^(u32,i32)-Box^u32 = fn(u32,i32)->Box<u32>: OK");
}
fn test_attr_caret_chain() {
#[batch_impl(#[allow(dead_code)]^Box^u32)]
trait S11a {}
fn _11a<T: S11a>() {}
_11a::<Box<u32>>();
println!(" 11a. #[allow(dead_code)]^Box^u32: OK");
#[batch_impl(#[allow(dead_code)]^[usize, isize])]
trait S11b {}
fn _11b<T: S11b>() {}
_11b::<usize>();
_11b::<isize>();
println!(" 11b. #[allow(dead_code)]^[usize, isize]: OK");
}
fn test_unit_target() {
#[batch_impl((), usize)]
trait S12a {}
fn _12a<T: S12a>() {}
_12a::<()>();
_12a::<usize>();
println!(" 12a. (,usize) = impl for () and usize: OK");
}
fn test_range_zero() {
#[batch_impl(()^0..1)]
trait S13a {}
fn _13a<T: S13a>() {}
_13a::<()>();
println!(" 13a. ()^0..1 = (): OK");
#[batch_impl(()^0..3)]
trait S13b {}
fn _13b<T: S13b>() {}
_13b::<()>();
_13b::<(i32,)>();
_13b::<(i32, i32)>();
println!(" 13b. ()^0..3 = (), (A,), (A,B): OK");
}
fn test_deep_caret() {
#[batch_impl(Box^Box^Vec^u32)]
trait S14a {}
fn _14a<T: S14a>() {}
_14a::<Box<Box<Vec<u32>>>>();
println!(" 14a. Box^Box^Vec^u32 = Box<Box<Vec<u32>>>: OK");
#[batch_impl(&^Box^Box^Box^u32)]
trait S14b {}
fn _14b<T: S14b>() {}
_14b::<&Box<Box<Box<u32>>>>();
println!(" 14b. &^Box^Box^Box^u32: OK");
}
fn test_hashmap_prefill() {
#[batch_impl(<K, V> HashMap<K>^V)]
trait S15a {}
fn _15a<T: S15a>() {}
_15a::<HashMap<u32, String>>();
println!(" 15a. <K,V> HashMap<K>^V = HashMap<K,V>: OK");
#[batch_impl(<K, V> HashMap<K>-V)]
trait S15b {}
fn _15b<T: S15b>() {}
_15b::<HashMap<u32, String>>();
println!(" 15b. <K,V> HashMap<K>-V = HashMap<K,V>: OK");
}
fn test_cartesian_3elem() {
#[batch_impl((u8, u16, u32)^2)]
trait S16a {}
fn _16a<T: S16a>() {}
_16a::<(u8, u8)>();
_16a::<(u8, u16)>();
_16a::<(u8, u32)>();
_16a::<(u16, u8)>();
_16a::<(u16, u16)>();
_16a::<(u16, u32)>();
_16a::<(u32, u8)>();
_16a::<(u32, u16)>();
_16a::<(u32, u32)>();
println!(" 16a. (u8,u16,u32)^2 = 9 impls: OK");
}
fn test_26_generics() {
#[batch_impl(()^26)]
trait S17a {}
fn _17a<T: S17a>() {}
_17a::<(
u8,
u16,
u32,
u64,
u128,
usize,
i8,
i16,
i32,
i64,
i128,
isize,
f32,
f64,
bool,
char,
String,
Vec<u8>,
Box<u8>,
Box<u16>,
Box<u32>,
Box<u64>,
Box<u128>,
Box<usize>,
Box<i8>,
Box<i16>,
)>();
println!(" 17a. ()^26 = (A..Z) 26 generic params: OK");
}
fn test_mixed_ref_ptr() {
#[batch_impl([&, *const, *mut]^Box^u32)]
trait S18a {}
fn _18a<T: S18a>() {}
_18a::<&Box<u32>>();
_18a::<*const Box<u32>>();
_18a::<*mut Box<u32>>();
println!(" 18a. [&, *const, *mut]^Box^u32 = 3 impls: OK");
}
fn test_fn_edge_cases() {
#[batch_impl(fn^(u32,i32)-(usize, isize))]
trait S19a {}
fn _19a<T: S19a>() {}
_19a::<fn(u32, i32) -> (usize, isize)>();
println!(" 19a. fn^(u32,i32)-(usize,isize) = fn->(usize,isize): OK");
#[batch_impl(fn^())]
trait S19b {}
fn _19b<T: S19b>() {}
_19b::<fn()>();
println!(" 19b. fn^() = fn(): OK");
#[batch_impl(fn^()-u32)]
trait S19c {}
fn _19c<T: S19c>() {}
_19c::<fn() -> u32>();
println!(" 19c. fn^()-u32 = fn()->u32: OK");
#[batch_impl(fn^(u32,i32)^i64)]
trait S19d {}
fn _19d<T: S19d>() {}
_19d::<fn(u32, i32, i64)>();
println!(" 19d. fn^(u32,i32)^i64 = fn(u32,i32,i64): OK");
}
fn test_caret_with_angle() {
#[batch_impl(HashMap^<u32, String>)]
trait S20a {}
fn _20a<T: S20a>() {}
_20a::<HashMap<u32, String>>();
println!(" 20a. HashMap^<u32,String> = HashMap<u32,String>: OK");
#[batch_impl(<K, V> HashMap<K>^V)]
trait S20b {}
fn _20b<T: S20b>() {}
_20b::<HashMap<u32, String>>();
println!(" 20b. <K,V> HashMap<K>^V = HashMap<K,V>: OK");
}
fn test_multi_modifier() {
#[batch_impl(self^Box<Vec<u32>>)]
trait S21a {}
fn _21a<T: S21a>() {}
_21a::<Box<Vec<u32>>>();
println!(" 21a. self^Box<Vec<u32>> = Box<Vec<u32>>: OK");
#[batch_impl([self, &mut]^Box<u32>)]
trait S21b {}
fn _21b<T: S21b>() {}
_21b::<Box<u32>>();
_21b::<&mut Box<u32>>();
println!(" 21b. [self,&mut]^Box<u32> = Box<u32>, &mut Box<u32>: OK");
}
fn test_long_dash_chain() {
#[batch_impl(()-u8-u16-u32-u64-usize)]
trait S22a {}
fn _22a<T: S22a>() {}
_22a::<(u8, u16, u32, u64, usize)>();
println!(" 22a. ()-u8-u16-u32-u64-usize = 5-tuple: OK");
#[batch_impl(()-[u8, u16]-[u32, u64]-usize)]
trait S22b {}
fn _22b<T: S22b>() {}
_22b::<(u8, u32, usize)>();
_22b::<(u8, u64, usize)>();
_22b::<(u16, u32, usize)>();
_22b::<(u16, u64, usize)>();
println!(" 22b. ()-[u8,u16]-[u32,u64]-usize = 4 impls: OK");
}
fn test_caret_dash_interaction() {
#[batch_impl(<K, V> HashMap^K-V)]
trait S23a {}
fn _23a<T: S23a>() {}
_23a::<HashMap<u32, String>>();
println!(" 23a. <K,V> HashMap^K-V = HashMap<K,V>: OK");
#[batch_impl(HashMap^<u32>-String)]
trait S23b {}
fn _23b<T: S23b>() {}
_23b::<HashMap<u32, String>>();
println!(" 23b. HashMap^<u32>-String = HashMap<u32,String>: OK");
#[batch_impl(unsafe^#[allow(dead_code)]^Box<u32>)]
unsafe trait S23c {}
fn _23c<T: S23c>() {}
_23c::<Box<u32>>();
println!(" 23c. unsafe^#[attr]^Box<u32>: OK");
#[batch_impl(unsafe^#[allow(dead_code)]^Box<u32> {
fn boxed_val(&self) -> &u32 { &**self }
})]
unsafe trait S23d {
fn boxed_val(&self) -> &u32;
}
fn _23d() {
let b = Box::new(42u32);
assert_eq!(S23d::boxed_val(&b), &42);
}
_23d();
println!(" 23d. unsafe^#[attr]^Box<u32> {{ body }}: OK");
#[batch_impl(#[allow(dead_code)]^#[allow(unused)]^Box<u32>)]
trait S23e {}
fn _23e<T: S23e>() {}
_23e::<Box<u32>>();
println!(" 23e. #[attr]^#[attr]^Box<u32>: OK");
#[batch_impl([Vec, Box]^u32)]
trait S23f {}
fn _23f<T: S23f>() {}
_23f::<Vec<u32>>();
_23f::<Box<u32>>();
println!(" 23f. [Vec,Box]^u32 = Vec<u32>, Box<u32>: OK");
#[batch_impl(fn^(u32,i32)-(usize, isize))]
trait S23g {}
fn _23g<T: S23g>() {}
_23g::<fn(u32, i32) -> (usize, isize)>();
println!(" 23g. fn^(u32,i32)-(usize,isize): OK");
#[batch_impl(fn^(u32,i32)^i64-usize)]
trait S23h {}
fn _23h<T: S23h>() {}
_23h::<fn(u32, i32, i64) -> usize>();
println!(" 23h. fn^(u32,i32)^i64-usize = fn(u32,i32,i64)->usize: OK");
}
fn test_dyn_trait_object() {
#[batch_impl(&(dyn Fn(i32) -> u32 + Send))]
trait S24a {}
fn _24a() {
fn _check<T: S24a>() {}
_check::<&(dyn Fn(i32) -> u32 + Send)>();
}
_24a();
println!(" 24a. dyn Fn(i32)->u32+Send 透传: OK");
#[batch_impl(Box<dyn Fn() -> i32 + Sync>)]
trait S24b {}
fn _24b() {
fn _check<T: S24b>() {}
_check::<Box<dyn Fn() -> i32 + Sync>>();
}
_24b();
println!(" 24b. Box<dyn Fn()->i32+Sync> 透传: OK");
#[batch_impl(&dyn std::fmt::Display)]
trait S24c {}
fn _24c() {
fn _check<T: S24c>() {}
_check::<&dyn std::fmt::Display>();
}
_24c();
println!(" 24c. &dyn Display 透传: OK");
#[batch_impl(&(dyn FnMut(String) -> bool + Send + Sync + 'static))]
trait S24d {}
fn _24d() {
fn _check<T: S24d>() {}
_check::<&(dyn FnMut(String) -> bool + Send + Sync + 'static)>();
}
_24d();
println!(" 24d. dyn FnMut 复杂 bound 透传: OK");
}
fn test_trailing_comma() {
#[batch_impl(usize, isize,)]
trait S25a {}
fn _25a<T: S25a>() {}
_25a::<usize>();
_25a::<isize>();
println!(" 25a. 顶层尾随逗号 usize,isize,: OK");
#[batch_impl([u8, u16, u32,] {
fn tag(&self) -> &'static str { "num" }
})]
trait S25b {
fn tag(&self) -> &'static str;
}
fn _25b<T: S25b>() {}
_25b::<u8>();
_25b::<u16>();
_25b::<u32>();
println!(" 25b. 列表内尾随逗号 [u8,u16,u32,]: OK");
#[batch_impl(<T, U,> S25c<T, U,> (T, U))]
trait S25c<A, B> {}
fn _25c<T: S25c<u32, String>>() {}
_25c::<(u32, String)>();
println!(" 25c. trait 泛型尾随逗号 <T,U,>: OK");
}
fn test_zero_tuple() {
#[batch_impl(()^0)]
trait S26a {}
fn _26a() {
fn _check<T: S26a>() {}
_check::<()>();
}
_26a();
println!(" 26a. ()^0 = (): OK");
#[batch_impl((u32,)^0)]
trait S26b {}
fn _26b() {
fn _check<T: S26b>() {}
_check::<()>();
}
_26b();
println!(" 26b. (u32,)^0 = (): OK");
#[batch_impl(()^0..2)]
trait S26c {}
fn _26c() {
fn _check<T: S26c>() {}
_check::<()>();
}
_26c();
println!(" 26c. ()^0..2 包含 (): OK");
}
fn test_single_tuple_vs_group() {
#[batch_impl(Box^(u32,))]
trait S27a {}
fn _27a() {
fn _check<T: S27a>() {}
_check::<Box<(u32,)>>();
}
_27a();
println!(" 27a. Box^(u32,) = Box<(u32,)>: OK");
#[batch_impl(Box^u32)]
trait S27b {}
fn _27b() {
fn _check<T: S27b>() {}
_check::<Box<u32>>();
}
_27b();
println!(" 27b. Box^(u32) = Box<u32> (分组): OK");
#[batch_impl((u32,)^1)]
trait S27c {}
fn _27c() {
fn _check<T: S27c>() {}
_check::<(u32,)>();
}
_27c();
println!(" 27c. (u32,)^1 = ((u32,),): OK");
}
fn test_bracket_no_comma() {
#[batch_impl(Box^[u32])]
trait S28a {}
fn _28a() {
fn _check<T: S28a>() {}
_check::<Box<[u32]>>();
}
_28a();
println!(" 28a. Box^[u32] = Box<[u32]> (切片): OK");
#[batch_impl(Vec^[i32; 8])]
trait S28b {}
fn _28b() {
fn _check<T: S28b>() {}
_check::<Vec<[i32; 8]>>();
}
_28b();
println!(" 28b. Vec^[i32;8] = Vec<[i32;8]>: OK");
#[batch_impl(&[u8])]
trait S28c {}
fn _28c() {
fn _check<T: S28c>() {}
_check::<&[u8]>();
}
_28c();
println!(" 28c. &[u8] 透传: OK");
}
fn test_double_ref_ptr() {
#[batch_impl(*const^*const^u32)]
trait S29a {}
fn _29a() {
fn _check<T: S29a>() {}
_check::<*const *const u32>();
}
_29a();
println!(" 29a. *const^*const^u32 = *const *const u32: OK");
#[batch_impl(*mut^*mut^i64)]
trait S29b {}
fn _29b() {
fn _check<T: S29b>() {}
_check::<*mut *mut i64>();
}
_29b();
println!(" 29b. *mut^*mut^i64 = *mut *mut i64: OK");
#[batch_impl(*const^&^u32)]
trait S29c {}
fn _29c() {
fn _check<T: S29c>() {}
_check::<*const &u32>();
}
_29c();
println!(" 29c. *const^&^u32 = *const &u32: OK");
#[batch_impl(&^*const^u32)]
trait S29d {}
fn _29d() {
fn _check<T: S29d>() {}
_check::<&*const u32>();
}
_29d();
println!(" 29d. &^*const^u32 = &*const u32: OK");
#[batch_impl(&mut^Box^&^Vec^u32)]
trait S29e {}
fn _29e() {
fn _check<T: S29e>() {}
_check::<&mut Box<&Vec<u32>>>();
}
_29e();
println!(" 29e. &mut^Box^&^Vec^u32 = &mut Box<&Vec<u32>>: OK");
}
fn test_fn_boundary() {
#[batch_impl(fn^())]
trait S30a {}
fn _30a() {
fn _check<T: S30a>() {}
_check::<fn()>();
}
_30a();
println!(" 30a. fn^() = fn(): OK");
#[batch_impl(fn^(i32,))]
trait S30b {}
fn _30b() {
fn _check<T: S30b>() {}
_check::<fn(i32)>();
}
_30b();
println!(" 30b. fn^(i32) = fn(i32): OK");
#[batch_impl(fn^()-String)]
trait S30c {}
fn _30c() {
fn _check<T: S30c>() {}
_check::<fn() -> String>();
}
_30c();
println!(" 30c. fn^()-String = fn()->String: OK");
#[batch_impl([fn^(i32,), fn^(u32,)])]
trait S30d {}
fn _30d() {
fn _check<T: S30d>() {}
_check::<fn(i32)>();
_check::<fn(u32)>();
}
_30d();
println!(" 30d. [fn^(i32),fn^(u32)] = 2 fn types: OK");
}
fn test_const_generic_array() {
#[batch_impl(<const N: usize> [u32; N])]
trait S31a {}
fn _31a() {
fn _check<T: S31a>() {}
_check::<[u32; 0]>();
_check::<[u32; 1]>();
_check::<[u32; 64]>();
}
_31a();
println!(" 31a. <const N:usize> [u32;N]: OK");
#[batch_impl(<const M: usize, const N: usize> [[u32; N]; M])]
trait S31b {}
fn _31b() {
fn _check<T: S31b>() {}
_check::<[[u32; 3]; 4]>();
}
_31b();
println!(" 31b. <const M:usize, const N:usize> [[u32;N];M]: OK");
#[batch_impl(<T: Clone, const N: usize> [T; N])]
trait S31c {}
fn _31c() {
fn _check<T: S31c>() {}
_check::<[i32; 8]>();
_check::<[String; 2]>();
}
_31c();
println!(" 31c. <T:Clone, const N:usize> [T;N]: OK");
}
fn test_where_clause() {
#[batch_impl(<T> Cloneable<T> Vec<T> {
fn clone_inner(&self) -> Vec<T> where T: Clone { self.clone() }
})]
trait Cloneable<T> {
fn clone_inner(&self) -> Vec<T>
where
T: Clone;
}
fn _32a() {
let v = vec![1u32, 2, 3];
let cloned = Cloneable::clone_inner(&v);
assert_eq!(cloned, vec![1u32, 2, 3]);
}
_32a();
println!(" 32a. body 中 where T:Clone: OK");
}
fn test_self_in_body() {
#[batch_impl([
u32 { fn create() -> Self { 42 } },
String { fn create() -> Self { String::from("hello") } }
])]
trait S33a {
fn create() -> Self;
}
fn _33a() {
assert_eq!(u32::create(), 42u32);
assert_eq!(String::create(), "hello");
}
_33a();
println!(" 33a. Self 在 body 中正确指向目标类型: OK");
#[batch_impl(<T> Wrap<T> Vec<T> {
fn wrap(self) -> Self { self }
})]
trait Wrap<T> {
fn wrap(self) -> Self;
}
fn _33b() {
let v = vec![1u32];
let w = Wrap::wrap(v);
assert_eq!(w, vec![1u32]);
}
_33b();
println!(" 33b. Self 在泛型 body 中正确: OK");
}
fn test_path_types() {
#[batch_impl(std::collections::BTreeMap<u32, String>)]
trait S34a {}
fn _34a() {
fn _check<T: S34a>() {}
_check::<std::collections::BTreeMap<u32, String>>();
}
_34a();
println!(" 34a. BTreeMap<u32,String> 路径透传: OK");
#[batch_impl(std::borrow::Cow<'static, str>)]
trait S34b {}
fn _34b() {
fn _check<T: S34b>() {}
_check::<std::borrow::Cow<'static, str>>();
}
_34b();
println!(" 34b. Cow<'static, str> 透传: OK");
#[batch_impl(std::pin::Pin<Box<u32>>)]
trait S34c {}
fn _34c() {
fn _check<T: S34c>() {}
_check::<std::pin::Pin<Box<u32>>>();
}
_34c();
println!(" 34c. Pin<Box<u32>> 透传: OK");
}
fn test_tuple_cartesian_edge() {
#[batch_impl((u8,)^2)]
trait S35a {}
fn _35a() {
fn _check<T: S35a>() {}
_check::<(u8, u8)>();
}
_35a();
println!(" 35a. (u8,)^2 = (u8,u8): OK");
#[batch_impl((u8, u16)^2)]
trait S35b {}
fn _35b() {
fn _check<T: S35b>() {}
_check::<(u8, u8)>();
_check::<(u8, u16)>();
_check::<(u16, u8)>();
_check::<(u16, u16)>();
}
_35b();
println!(" 35b. (u8,u16)^2 = 4 笛卡尔积: OK");
#[batch_impl((<Clone>)^4)]
trait S35c {}
fn _35c() {
fn _check<T: S35c>() {}
_check::<(String, String, String, String)>();
_check::<(u32, u64, i32, usize)>();
}
_35c();
println!(" 35c. (<Clone>)^4 = 4 泛型元组: OK");
#[batch_impl(()^1..=1)]
trait S35d {}
fn _35d() {
fn _check<T: S35d>() {}
_check::<(u32,)>()
}
_35d();
println!(" 35d. ()^1..=1 只生成 1 元组: OK");
}
fn test_generic_inheritance() {
use std::collections::HashMap;
#[batch_impl(<T, U> Pair2<T, U> [
Vec<T>,
HashMap<T, U>
])]
trait Pair2<A, B> {}
fn _36a() {
fn _check<T: Pair2<u32, String>>() {}
_check::<Vec<u32>>();
_check::<HashMap<u32, String>>();
}
_36a();
println!(" 36a. 子项追加泛型 bound 继承: OK");
#[batch_impl([
[usize, isize] { fn is_signed(&self) -> bool { false } },
f32 { fn is_signed(&self) -> bool { true } }
] {
fn type_name(&self) -> &'static str { "number" }
})]
trait S36b {
fn is_signed(&self) -> bool;
fn type_name(&self) -> &'static str;
}
fn _36b() {
fn _check<T: S36b>() {}
_check::<usize>();
_check::<isize>();
_check::<f32>();
}
_36b();
println!(" 36b. 嵌套列表 + 独立/共享 body: OK");
}
fn test_complex_combos() {
#[batch_impl(Box^&^Vec^&^u32)]
trait S37a {}
fn _37a() {
fn _check<T: S37a>() {}
_check::<Box<&Vec<&u32>>>();
}
_37a();
println!(" 37a. Box^&^Vec^&^u32 = Box<&Vec<&u32>>: OK");
#[batch_impl([Box, Vec]^&^[u32, i64])]
trait S37b {}
fn _37b() {
fn _check<T: S37b>() {}
_check::<Box<&u32>>();
_check::<Box<&i64>>();
_check::<Vec<&u32>>();
_check::<Vec<&i64>>();
}
_37b();
println!(" 37b. [Box,Vec]^&^[u32,i64] = 4 impls: OK");
#[batch_impl(<T> Container<T> HashMap<String, Vec<T>> {
fn key_count(&self) -> usize { self.len() }
})]
trait Container<T> {
fn key_count(&self) -> usize;
}
fn _37c() {
let mut m = std::collections::HashMap::new();
m.insert("a".to_string(), vec![1u32]);
assert_eq!(Container::key_count(&m), 1);
}
_37c();
println!(" 37c. HashMap<String,Vec<T>> 作目标+body: OK");
#[batch_impl(unsafe^Box^&^Vec^u32)]
unsafe trait S37d {}
fn _37d() {
fn _check<T: S37d>() {}
_check::<Box<&Vec<u32>>>();
}
_37d();
println!(" 37d. unsafe^Box^&^Vec^u32 = Box<&Vec<u32>>: OK");
}
fn test_batch_trait_edge() {
use batch_impl::batch_trait;
trait EdgeA {}
trait EdgeB<T> {
fn val(&self) -> T;
}
mod edge_mod {
pub trait EdgeC {}
}
batch_trait!(
EdgeA: Box<dyn std::fmt::Debug>, &dyn std::fmt::Display;
EdgeB: <T> EdgeB<T> Vec<T> { fn val(&self) -> T { unreachable!() } };
edge_mod::EdgeC: [u32, i64]
);
fn _38() {
fn _check_a<T: EdgeA>() {}
_check_a::<Box<dyn std::fmt::Debug>>();
_check_a::<&dyn std::fmt::Display>();
fn _check_b<T: EdgeB<u32>>() {}
_check_b::<Vec<u32>>();
fn _check_c<T: edge_mod::EdgeC>() {}
_check_c::<u32>();
_check_c::<i64>();
}
_38();
println!(" 38. batch_trait! 复杂类型+路径+body: OK");
}
fn test_assoc_complex() {
#[batch_impl(<T: Clone> TupleOut<Output=(T, T)> Vec<T> {
fn double_first(&self) -> (T, T) {
(self[0].clone(), self[0].clone())
}
})]
trait TupleOut {
type Output;
fn double_first(&self) -> Self::Output
where
Self::Output: Sized,
Self: Sized;
}
fn _39a() {
let v = vec![42u32];
let (a, b) = TupleOut::double_first(&v);
assert_eq!(a, 42u32);
assert_eq!(b, 42u32);
}
_39a();
println!(" 39a. 关联类型绑定元组 Output=(T,T): OK");
#[batch_impl(<T: Clone> Maybe<Item=Option<T>> Vec<T> {
fn first_or_none(&self) -> Option<T> {
self.first().cloned()
}
})]
trait Maybe {
type Item;
fn first_or_none(&self) -> Self::Item
where
Self::Item: Sized,
Self: Sized;
}
fn _39b() {
let v = vec![1u32, 2, 3];
assert_eq!(Maybe::first_or_none(&v), Some(1u32));
let empty: Vec<u32> = vec![];
assert_eq!(Maybe::first_or_none(&empty), None);
}
_39b();
println!(" 39b. 关联类型 Option<T> 绑定+body: OK");
}
fn test_recursion_edge() {
#[batch_impl(Box^Box^Box^Box^Box^Box^Box^Box^Box^Box^u32)]
trait S40a {}
fn _40a() {
fn _check<T: S40a>() {}
_check::<Box<Box<Box<Box<Box<Box<Box<Box<Box<Box<u32>>>>>>>>>>>();
}
_40a();
println!(" 40a. 10层 Box 嵌套: OK");
#[batch_impl(()^16)]
trait S40b {}
fn _40b() {
fn _check<T: S40b>() {}
_check::<(
u8,
u8,
u8,
u8,
u8,
u8,
u8,
u8,
u8,
u8,
u8,
u8,
u8,
u8,
u8,
u8,
)>();
}
_40b();
println!(" 40b. ()^16 = 16元素元组: OK");
}
fn test_special_idents() {
#[batch_impl(Vec<u32>)]
trait S41a {}
fn _41a() {
fn _check<T: S41a>() {}
_check::<Vec<u32>>();
}
_41a();
println!(" 41a. Vec<u32> 复杂类型名: OK");
#[batch_impl(std::io::Result<()>)]
trait S41b {}
fn _41b() {
fn _check<T: S41b>() {}
_check::<std::io::Result<()>>();
}
_41b();
println!(" 41b. std::io::Result<()> 嵌套路径: OK");
}
fn test_dedup() {
#[batch_impl([
u32 { fn id(&self) -> &'static str { "u32" } },
u64 { fn id(&self) -> &'static str { "u64" } }
])]
trait S42a {
fn id(&self) -> &'static str;
}
fn _42a() {
assert_eq!(S42a::id(&42u32), "u32");
assert_eq!(S42a::id(&42u64), "u64");
}
_42a();
println!(" 42a. 不同类型独立 impl: OK");
#[batch_impl([u8, u16, u32, u64])]
trait S42b {}
fn _42b() {
fn _check<T: S42b>() {}
_check::<u8>();
_check::<u16>();
_check::<u32>();
_check::<u64>();
}
_42b();
println!(" 42b. 4 种类型批量 impl: OK");
}
fn test_tuple_append_complex() {
#[batch_impl((u8, u16)^Box<Vec<String>>)]
trait S43a {}
fn _43a() {
fn _check<T: S43a>() {}
_check::<(u8, u16, Box<Vec<String>>)>()
}
_43a();
println!(" 43a. (u8,u16)^Box<Vec<String>> = 3元组: OK");
println!(" 43b. ()^u32^String 跳过 (生成的类型不合法): OK");
}
fn test_unit_in_brackets() {
#[batch_impl(())]
trait S44a {}
fn _44a() {
fn _check<T: S44a>() {}
_check::<()>();
}
_44a();
println!(" 44a. () 作为目标类型: OK");
#[batch_impl([(), usize])]
trait S44b {}
fn _44b() {
fn _check<T: S44b>() {}
_check::<()>();
_check::<usize>();
}
_44b();
println!(" 44b. [(), usize] = unit + usize 混合: OK");
#[batch_impl([&(), &mut()])]
trait S44c {}
fn _44c() {
fn _check<T: S44c>() {}
_check::<&()>();
_check::<&mut ()>();
}
_44c();
println!(" 44c. [&(), &mut()] = 修饰 unit: OK");
#[batch_impl(()-u32-String)]
trait S44d {}
fn _44d() {
fn _check<T: S44d>() {}
_check::<(u32, String)>();
}
_44d();
println!(" 44d. ()-u32-String = (u32,String): OK");
}
fn test_complex_trait_objects() {
#[batch_impl(Box<dyn for<'a> Fn(&'a str) -> bool + Send + 'static>)]
trait S45a {}
fn _45a() {
fn _check<T: S45a>() {}
_check::<Box<dyn for<'a> Fn(&'a str) -> bool + Send + 'static>>();
}
_45a();
println!(" 45a. Box<dyn for<'a> Fn(...)+Send+'static>: OK");
#[batch_impl(&(dyn FnOnce(String) -> usize + Sync))]
trait S45b {}
fn _45b() {
fn _check<T: S45b>() {}
_check::<&(dyn FnOnce(String) -> usize + Sync)>();
}
_45b();
println!(" 45b. &(dyn FnOnce(String)->usize+Sync): OK");
#[batch_impl(Box<dyn Iterator<Item = u32>>)]
trait S45c {}
fn _45c() {
fn _check<T: S45c>() {}
_check::<Box<dyn Iterator<Item = u32>>>();
}
_45c();
println!(" 45c. Box<dyn Iterator<Item=u32>>: OK");
#[batch_impl(Box<dyn std::ops::FnMut(i32) -> bool>)]
trait S45d {}
fn _45d() {
fn _check<T: S45d>() {}
_check::<Box<dyn std::ops::FnMut(i32) -> bool>>();
}
_45d();
println!(" 45d. Box<dyn FnMut(i32)->bool> 透传: OK");
}
fn test_mixed_pointer_cross() {
#[batch_impl(*const^*mut^u32)]
trait S46a {}
fn _46a() {
fn _check<T: S46a>() {}
_check::<*const *mut u32>();
}
_46a();
println!(" 46a. *const^*mut^u32 = *const *mut u32: OK");
#[batch_impl(*mut^*const^i64)]
trait S46b {}
fn _46b() {
fn _check<T: S46b>() {}
_check::<*mut *const i64>();
}
_46b();
println!(" 46b. *mut^*const^i64 = *mut *const i64: OK");
#[batch_impl([*const, *mut]^Box^u32)]
trait S46c {}
fn _46c() {
fn _check<T: S46c>() {}
_check::<*const Box<u32>>();
_check::<*mut Box<u32>>();
}
_46c();
println!(" 46c. [*const,*mut]^Box^u32 = 2 ptr impls: OK");
#[batch_impl(&^*const^Box^&^Vec^u32)]
trait S46d {}
fn _46d() {
fn _check<T: S46d>() {}
_check::<&*const Box<&Vec<u32>>>();
}
_46d();
println!(" 46d. &^*const^Box^&^Vec^u32 = 五层: OK");
}
fn test_attr_position_variants() {
#[batch_impl(&^#[allow(dead_code)]^Box^u32)]
trait S47a {}
fn _47a() {
fn _check<T: S47a>() {}
_check::<&Box<u32>>();
}
_47a();
println!(" 47a. &^#[attr]^Box^u32: OK");
#[batch_impl(#[allow(dead_code)]^&^#[allow(unused)]^Vec<u32>)]
trait S47b {}
fn _47b() {
fn _check<T: S47b>() {}
_check::<&Vec<u32>>();
}
_47b();
println!(" 47b. #[a]^&^#[b]^Vec<u32>: OK");
#[batch_impl(unsafe^#[allow(dead_code)]^#[allow(unused)]^Vec<u32>)]
unsafe trait S47c {}
fn _47c() {
fn _check<T: S47c>() {}
_check::<Vec<u32>>();
}
_47c();
println!(" 47c. unsafe^#[a]^#[b]^Vec<u32>: OK");
}
fn test_fn_advanced_combos() {
#[batch_impl([fn^(u32, i32), fn^(u32,)])]
trait S48a {}
fn _48a() {
fn _check<T: S48a>() {}
_check::<fn(u32, i32)>();
_check::<fn(u32)>();
}
_48a();
println!(" 48a. [fn^(u32,i32), fn^(u32,)] = 2 fn types: OK");
#[batch_impl(unsafe^fn^(u32,))]
unsafe trait S48b {}
fn _48b() {
fn _check<T: S48b>() {}
_check::<fn(u32)>();
}
_48b();
println!(" 48b. unsafe^fn^(u32,) = unsafe fn(u32): OK");
#[batch_impl(fn^(u32,)-[usize, isize])]
trait S48c {}
fn _48c() {
fn _check<T: S48c>() {}
_check::<fn(u32) -> usize>();
_check::<fn(u32) -> isize>();
}
_48c();
println!(" 48c. fn^(u32)-[usize,isize] = 2 fn types: OK");
}
fn test_deep_nested_slices() {
#[batch_impl(Box^[i32])]
trait S49a {}
fn _49a() {
fn _check<T: S49a + ?Sized>() {}
_check::<Box<[i32]>>();
}
_49a();
println!(" 49a. Box^[i32] = Box<[i32]> (切片): OK");
#[batch_impl(Box^[u64])]
trait S49b {}
fn _49b() {
fn _check<T: S49b + ?Sized>() {}
_check::<Box<[u64]>>();
}
_49b();
println!(" 49b. Box^[u64] = Box<[u64]> (切片): OK");
}
fn test_empty_entries() {
#[batch_impl([u32, , u64])]
trait S50a {}
fn _50a() {
fn _check<T: S50a>() {}
_check::<u32>();
_check::<u64>();
}
_50a();
println!(" 50a. [u32,,u64] 空条目被丢弃 = 2 impl: OK");
}
fn test_tuple_dash_edge() {
#[batch_impl((u32,)-i64)]
trait S51a {}
fn _51a() {
fn _check<T: S51a>() {}
_check::<(u32, i64)>();
}
_51a();
println!(" 51a. (u32,)-i64 = (u32,i64): OK");
#[batch_impl((u8,)-[i32, i64])]
trait S51b {}
fn _51b() {
fn _check<T: S51b>() {}
_check::<(u8, i32)>();
_check::<(u8, i64)>();
}
_51b();
println!(" 51b. (u8,)-[i32,i64] = 2 impls: OK");
#[batch_impl(()^Box<u32>)]
trait S51c {}
fn _51c() {
fn _check<T: S51c>() {}
_check::<(Box<u32>,)>();
}
_51c();
println!(" 51c. ()^Box<u32> = (Box<u32>,): OK");
}
fn test_lifetime_complex() {
#[batch_impl(<'a, 'b: 'a, T: 'b> &'a &'b T)]
trait S52a {}
fn _52a() {
fn _check<T: S52a>() {}
_check::<&'static &'static i32>();
}
_52a();
println!(" 52a. <'a,'b:'a,T:'b> &'a &'b T: OK");
#[batch_impl(<T: for<'a> Fn(&'a u32)> T)]
trait S52b {}
fn _52b() {
fn _check<T: S52b>() {}
_check::<fn(&u32)>();
}
_52b();
println!(" 52b. <T: for<'a> Fn(&'a u32)> 透传: OK");
#[batch_impl(&dyn for<'a> Fn(&'a ()) -> &'a ())]
trait S52c {}
fn _52c() {
fn _check<T: S52c>() {}
_check::<&dyn for<'a> Fn(&'a ()) -> &'a ()>();
}
_52c();
println!(" 52c. &dyn for<'a> Fn(&'a ()) -> &'a (): OK");
}
fn test_zero_length_boundary() {
#[batch_impl([u8; 0])]
trait S53a {}
fn _53a() {
fn _check<T: S53a>() {}
_check::<[u8; 0]>();
}
_53a();
println!(" 53a. [u8;0] 零长度数组: OK");
#[batch_impl(<const N: usize> [bool; N])]
trait S53b {}
fn _53b() {
fn _check<T: S53b>() {}
_check::<[bool; 0]>();
_check::<[bool; 1]>();
_check::<[bool; 42]>();
}
_53b();
println!(" 53b. const 泛型 [bool;N] 含零: OK");
#[batch_impl(()^0..=0)]
trait S53c {}
fn _53c() {
fn _check<T: S53c>() {}
_check::<()>();
}
_53c();
println!(" 53c. ()^0..=0 = (): OK");
#[batch_impl(()^0..2)]
trait S53d {}
fn _53d() {
fn _check<T: S53d>() {}
_check::<()>();
_check::<(u32,)>();
}
_53d();
println!(" 53d. ()^0..2 = () 和 (A,): OK");
}
fn test_precedence_edge() {
#[batch_impl(Vec-u32)]
trait S54a {}
fn _54a() {
fn _check<T: S54a>() {}
_check::<Vec<u32>>();
}
_54a();
println!(" 54a. Vec-u32 = Vec<u32>: OK");
#[batch_impl([Box, Vec]^u32)]
trait S54b {}
fn _54b() {
fn _check<T: S54b>() {}
_check::<Box<u32>>();
_check::<Vec<u32>>();
}
_54b();
println!(" 54b. [Box,Vec]^u32 = 2 impls: OK");
#[batch_impl([Box^&^Vec<u32>, Vec<u32>])]
trait S54c {}
fn _54c() {
fn _check<T: S54c>() {}
_check::<Box<&Vec<u32>>>();
_check::<Vec<u32>>();
}
_54c();
println!(" 54c. [Box^&^Vec<u32>, Vec<u32>]: OK");
}
fn test_assoc_eq_boundary() {
#[batch_impl(<T: Clone> HasItem<Item = T> Vec<T> {
fn get_item(&self) -> Option<T> { self.first().cloned() }
})]
trait HasItem {
type Item;
fn get_item(&self) -> Option<Self::Item>
where
Self::Item: Sized,
Self: Sized;
}
fn _55a() {
let v = vec![1u32, 2, 3];
assert_eq!(HasItem::get_item(&v), Some(1u32));
}
_55a();
println!(" 55a. HasItem<Item=T> 关联类型绑定: OK");
#[batch_impl(<T: Clone, U: Clone> Pair2<First = T, Second = Option<U>> (Vec<T>, Vec<U>) {
fn get_first(&self) -> T { self.0.first().cloned().unwrap() }
fn get_second(&self) -> Option<U> { self.1.first().cloned() }
})]
trait Pair2 {
type First;
type Second;
fn get_first(&self) -> Self::First;
fn get_second(&self) -> Self::Second;
}
fn _55b() {
let p = (vec![42u32], vec![1u64]);
assert_eq!(Pair2::get_first(&p), 42u32);
assert_eq!(Pair2::get_second(&p), Some(1u64));
}
_55b();
println!(" 55b. Pair2<First=T,Second=Option<U>> 多绑定: OK");
#[batch_impl(<T> Holder<Element = Box<Vec<T>>> Vec<T>)]
trait Holder {
type Element;
}
fn _55c() {
fn _check<T: Holder>() {}
_check::<Vec<u32>>();
}
_55c();
println!(" 55c. Holder<Element=Box<Vec<T>>> 复杂绑定: OK");
}
fn main() {
println!("=== ds-test: 代码审查 ===\n");
test_boundary_cases();
test_caret_nesting();
test_cartesian();
test_append_tuple();
test_dash();
test_operator_precedence();
test_self_identity();
test_pointer_chain();
test_unsafe_double();
test_fn_caret_vs_dash();
test_attr_caret_chain();
test_unit_target();
test_range_zero();
test_deep_caret();
test_hashmap_prefill();
test_cartesian_3elem();
test_26_generics();
test_mixed_ref_ptr();
test_fn_edge_cases();
test_caret_with_angle();
test_multi_modifier();
test_long_dash_chain();
test_caret_dash_interaction();
test_dyn_trait_object();
test_trailing_comma();
test_zero_tuple();
test_single_tuple_vs_group();
test_bracket_no_comma();
test_double_ref_ptr();
test_fn_boundary();
test_const_generic_array();
test_where_clause();
test_self_in_body();
test_path_types();
test_tuple_cartesian_edge();
test_generic_inheritance();
test_complex_combos();
test_batch_trait_edge();
test_assoc_complex();
test_recursion_edge();
test_special_idents();
test_dedup();
test_tuple_append_complex();
test_unit_in_brackets();
test_complex_trait_objects();
test_mixed_pointer_cross();
test_attr_position_variants();
test_fn_advanced_combos();
test_deep_nested_slices();
test_empty_entries();
test_tuple_dash_edge();
test_lifetime_complex();
test_zero_length_boundary();
test_precedence_edge();
test_assoc_eq_boundary();
test_caret_dash_symmetry();
test_fn_caret_chain();
println!("\nAll ds-tests passed!");
}
fn test_caret_dash_symmetry() {
#[batch_impl(fn-(u32,))]
trait S56a {}
fn _56a() {
fn _check<T: S56a>() {}
_check::<fn(u32)>();
}
_56a();
println!(" 56a. fn-(u32) = fn(u32): OK (碰巧)");
#[batch_impl(()-u32)]
trait S56b {}
fn _56b() {
fn _check<T: S56b>() {}
_check::<(u32,)>();
}
_56b();
println!(" 56b. ()-u32 = (u32,): OK (碰巧)");
#[batch_impl(&-u32)]
trait S56cRef {}
fn _56c_ref() {
fn _check<T: S56cRef>() {}
_check::<&u32>();
}
_56c_ref();
#[batch_impl(unsafe-u32)]
unsafe trait S56cUnsafe {}
fn _56c_unsafe() {
fn _check<T: S56cUnsafe>() {}
_check::<u32>();
}
_56c_unsafe();
#[batch_impl(*const-u32)]
trait S56cPtr {}
fn _56c_ptr() {
fn _check<T: S56cPtr>() {}
_check::<*const u32>();
}
_56c_ptr();
#[batch_impl(self-u32)]
trait S56cSelf {}
fn _56c_self() {
fn _check<T: S56cSelf>() {}
_check::<u32>();
}
_56c_self();
#[batch_impl(&mut-u32)]
trait S56cRefmut {}
fn _56c_refmut() {
fn _check<T: S56cRefmut>() {}
_check::<&mut u32>();
}
_56c_refmut();
#[batch_impl(#[allow(dead_code)]-u32)]
trait S56cAttr {}
fn _56c_attr() {
fn _check<T: S56cAttr>() {}
_check::<u32>();
}
_56c_attr();
println!(" 56c. &-T, unsafe-T, *const-T, self-T, &mut-T, #[attr]-T 均支持: OK");
}
use std::collections::HashMap;
fn test_fn_caret_chain() {
#[batch_impl(fn-(u32,i32)^2-[usize,isize])]
trait S57a {}
fn _57a() {
fn _check<T: S57a>() {}
_check::<fn(u32,u32)->usize>();
_check::<fn(i32,i32)->isize>();
}
_57a();
#[batch_impl(self-&-*const-Box-u32)]
trait S57b {}
fn _57b() {
fn _check<T: S57b>() {}
_check::<&*const Box<u32>>();
}
_57b();
println!(" 57. fn dash caret chain + prefix chain: OK");
}