题目 trait Trait { fn p(self); } impl<T> Trait for fn(T) { fn p(self) { print!("1"); } } impl<T> Trait for fn(&T) { fn...
题目 fn main() { let (.., x, y) = (0, 1, ..); print!("{}", b"066"[y][x]); } 关键 脱糖rust中有很多糖,有些甚至我们也无法判断它是不是糖。但是我们需要知...
题目 struct S { x: i32, } const S: S = S { x: 2 }; fn main() { let v = &mut S; v.x += 1; S.x += 1; print!("{}{}", v.x, S.x); } 关键 co...
题目 struct S(i32); impl std::ops::BitAnd<S> for () { type Output = (); fn bitand(self, rhs: S) { print!("{}", rhs.0); } } fn main()...
题目 macro_rules! m { ($($s:stmt)*) => { $( { stringify!($s); 1 } )<<* }; } fn main() { print!( "{}{}...
说明 倒不是说多牛逼,只是因为太菜鸡。因为各种源码充斥太多的宏,让我感觉畏惧,这才选择了先简单了解macro。而不是非得要从macro入手挑战自己。 经过前面的学习,虽然...
审题 // There is one other common type of pattern that would be nice to support -- // the wildcard or underscore pattern. The #[sorted] macro should check tha...
审题 // The macro won't need to define what it means for other sorts of patterns to // be sorted. It should be fine to trigger an error if any of the patterns...
审题 // When we checked enum definitions for sortedness, it was sufficient to compare // a single identifier (the name of the variant) for each variant. Match...
审题 // Get ready for a challenging step -- this test case is going to be a much // bigger change than the others so far. // // Not only do we want #[sorted]...
审题 // This test is similar to the previous where want to ensure that the macro // correctly generates an error when the input enum is out of order, but this...
题解 // At this point we have an enum and we need to check whether the variants // appear in sorted order! // // When your implementation notices a variant th...
审题 // The #[sorted] macro is only defined to work on enum types, so this is a test // to ensure that when it's attached to a struct (or anything else) it pr...
审题 // This test checks that an attribute macro #[sorted] exists and is imported // correctly in the module system. If you make the macro return an empty tok...
审题 // Suppose we wanted a seq invocation in which the upper bound is given by the // value of a const. Both macros and consts are compile-time things so thi...
社交账号:
我要举报该,理由是: