typo: docs/pumpkin-macros (#1451)

* updated documentations and applied a minor fix to resource_pack.rs config (suggested and autofixed by rustrover).

* fmt

Signed-off-by: Illyrius <fitimq@live.nl>

* init

Signed-off-by: Illyrius <fitimq@live.nl>

* fix unnecessary spaces
This commit is contained in:
Illyrius
2026-02-08 14:12:53 +01:00
committed by GitHub
parent 473bd5a57c
commit 8015b73882

View File

@@ -91,14 +91,14 @@ pub fn send_cancellable(input: TokenStream) -> TokenStream {
for stmt in block.stmts {
match stmt {
Stmt::Expr(expr, _) => {
// Check if it is a labeled block first
// Check if it is a labelled block first.
let mut is_special_block = false;
if let Expr::Block(ref b) = expr
&& let Some(ref label) = b.label
{
let label_name = label.name.ident.to_string();
if label_name == "after" {
after_block = Some(b.clone()); // Clone strictly necessary here as we split AST
after_block = Some(b.clone()); // Clone strictly necessary here as we split AST.
is_special_block = true;
} else if label_name == "cancelled" {
cancelled_block = Some(b.clone());
@@ -106,7 +106,7 @@ pub fn send_cancellable(input: TokenStream) -> TokenStream {
}
}
// If it wasn't a special block, it must be the event expression
// If it wasn't a special block, it must be the event expression.
if !is_special_block {
if server_expr.is_none() {
server_expr = Some(expr);
@@ -120,7 +120,7 @@ pub fn send_cancellable(input: TokenStream) -> TokenStream {
}
}
}
// Abort on other statements (like `let x = ...`) if strictness is desired
// Abort on other statements (like `let x = ...`) if strictness is desired.
_ => abort!(
stmt.span(),
"Only event expressions and labeled blocks allowed in `send_cancellable!`"
@@ -136,7 +136,7 @@ pub fn send_cancellable(input: TokenStream) -> TokenStream {
abort_call_site!("Event expression must be specified");
};
// Construct the if/else logic
// Construct the if/else logic.
let logic = match (after_block, cancelled_block) {
(Some(after), Some(cancelled)) => quote! {
if !event.cancelled { #after } else { #cancelled }
@@ -218,7 +218,7 @@ pub fn pumpkin_block(args: TokenStream, item: TokenStream) -> TokenStream {
}
};
// Combine original item and new impl
// Combine the original item and new impl.
let mut output = input_item;
output.extend(TokenStream::from(generated));
output
@@ -290,7 +290,7 @@ pub fn pumpkin_block_from_tag(args: TokenStream, item: TokenStream) -> TokenStre
// if fields.len() != 1 {
// abort!(
// fields.span(),
// "Block properties `struct`s must have exactly one field"
// "Block properties `struct's must have exactly one field"
// );
// }
// let field = fields.first().unwrap();
@@ -318,7 +318,7 @@ pub fn pumpkin_block_from_tag(args: TokenStream, item: TokenStream) -> TokenStre
// ),
// }
// }
// _ => abort_call_site!("Block properties can only be `enum`s or `struct`s"),
// _ => abort_call_site!("Block properties can only be `enum`s or `struct's"),
// };
// let values = variants.iter().enumerate().map(|(i, v)| match is_enum {
@@ -406,7 +406,7 @@ pub fn pumpkin_block_from_tag(args: TokenStream, item: TokenStream) -> TokenStre
#[rustfmt::skip]
#[proc_macro_derive(PacketWrite, attributes(serial))]
pub fn derive_serialize(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as syn::DeriveInput);
let input = parse_macro_input!(input as DeriveInput);
let name = &input.ident;
let fields = if let syn::Data::Struct(data) = &input.data {
@@ -460,7 +460,7 @@ pub fn derive_serialize(input: TokenStream) -> TokenStream {
#[rustfmt::skip]
#[proc_macro_derive(PacketRead, attributes(serial))]
pub fn derive_deserialize(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as syn::DeriveInput);
let input = parse_macro_input!(input as DeriveInput);
let name = &input.ident;
let fields = if let syn::Data::Struct(data) = &input.data {