From b7c966d06f4d7b84023da1e087bd0f7d604cfecd Mon Sep 17 00:00:00 2001 From: Lorenzo Murarotto Date: Sat, 14 Dec 2024 12:43:57 +0100 Subject: [PATCH] docs: fix a few typos --- .idea/axum_typed_multipart.iml | 1 + macros/src/impls/try_from_field.rs | 7 ++++--- macros/src/impls/try_from_multipart.rs | 2 +- macros/tests/test_strict.rs | 2 +- src/base_multipart.rs | 2 +- src/lib.rs | 20 ++++++++++---------- src/typed_multipart.rs | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.idea/axum_typed_multipart.iml b/.idea/axum_typed_multipart.iml index 5882bf8..7afae89 100644 --- a/.idea/axum_typed_multipart.iml +++ b/.idea/axum_typed_multipart.iml @@ -6,6 +6,7 @@ + diff --git a/macros/src/impls/try_from_field.rs b/macros/src/impls/try_from_field.rs index 0779dfa..2c59a11 100644 --- a/macros/src/impls/try_from_field.rs +++ b/macros/src/impls/try_from_field.rs @@ -62,7 +62,7 @@ pub fn macro_impl(input: TokenStream) -> TokenStream { } }); - quote! { + let res = quote! { #[axum::async_trait] impl ::axum_typed_multipart::TryFromField for #ident { async fn try_from_field( @@ -78,6 +78,7 @@ pub fn macro_impl(input: TokenStream) -> TokenStream { } } } - } - .into() + }; + + res.into() } diff --git a/macros/src/impls/try_from_multipart.rs b/macros/src/impls/try_from_multipart.rs index 869d4e3..6d9a9d9 100644 --- a/macros/src/impls/try_from_multipart.rs +++ b/macros/src/impls/try_from_multipart.rs @@ -56,7 +56,7 @@ impl FieldData { } } - /// Parse the supplied human readable size limit into a byte limit. + /// Parse the supplied human-readable size limit into a byte limit. fn limit_bytes(&self) -> Option { match self.limit.as_deref() { None => Some(DEFAULT_FIELD_SIZE_LIMIT_BYTES), diff --git a/macros/tests/test_strict.rs b/macros/tests/test_strict.rs index 1217ad6..7d83098 100644 --- a/macros/tests/test_strict.rs +++ b/macros/tests/test_strict.rs @@ -50,7 +50,7 @@ async fn test_strict_unknown_field() { } #[tokio::test] -async fn test_strict_deplicate_field() { +async fn test_strict_duplicate_field() { async fn handler(_: TypedMultipart) { panic!("should not be called"); } diff --git a/src/base_multipart.rs b/src/base_multipart.rs index 96afe60..77f3f63 100644 --- a/src/base_multipart.rs +++ b/src/base_multipart.rs @@ -5,7 +5,7 @@ use axum::response::IntoResponse; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; -/// Used as as an argument for axum [Handlers](axum::handler::Handler). +/// Used as an argument for axum [Handlers](axum::handler::Handler). /// /// Implements [FromRequest] when the generic argument implements the /// [TryFromMultipart] trait and the generic rejection implements the diff --git a/src/lib.rs b/src/lib.rs index e9f4764..1ebb11c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,8 +42,8 @@ //! //! If the request body is malformed the request will be aborted with an error. //! -//! An error will be returned if at least one field is missing, with the exception of [Option] and -//! [Vec] types, which will be set respectively as [Option::None] and `[]`. +//! An error will be returned if at least one field is missing, except for [Option] and +//! [Vec] types, which will be set respectively as [None] and `[]`. //! //! ```rust,no_run #![doc = include_str!("../examples/basic.rs")] @@ -118,7 +118,7 @@ //! ### Field metadata //! //! If you need access to the field metadata (e.g. the field headers like file name or content -//! type) you can use the [FieldData](crate::FieldData) struct to wrap your field. +//! type) you can use the [FieldData](FieldData) struct to wrap your field. //! ```rust //! use axum::body::Bytes; //! use axum_typed_multipart::{FieldData, TryFromMultipart}; @@ -172,10 +172,10 @@ //! //! ### Strict mode //! -//! By default the derive macro will store the last occurrence of a field and it will ignore +//! By default, the derive macro will store the last occurrence of a field, and it will ignore //! unknown fields. This behavior can be changed by using the `strict` parameter in the derive //! macro. This will make the macro throw an error if the request contains multiple fields with the -//! same name or if it contains unknown fields. In addition when using strict mode sending fields +//! same name or if it contains unknown fields. In addition, when using strict mode sending fields //! with a missing or empty name will result in an error. //! ```rust //! use axum_typed_multipart::TryFromMultipart; @@ -230,19 +230,19 @@ //! [TryFromField](crate::TryFromField) trait for your type. This will allow the derive macro to //! generate the [TryFromMultipart](crate::TryFromMultipart) implementation automatically. Instead //! of implementing the trait directly, it is recommended to implement the -//! [TryFromChunks](crate::TryFromChunks) trait and the [TryFromField](crate::TryFromField) trait +//! [TryFromChunks](TryFromChunks) trait and the [TryFromField](crate::TryFromField) trait //! will be implemented automatically. This is recommended since you won't need to manually //! implement the size limit logic. //! -//! To implement the [TryFromChunks](crate::TryFromChunks) trait for external types you will need +//! To implement the [TryFromChunks](TryFromChunks) trait for external types you will need //! to create a newtype wrapper and implement the trait for the wrapper. //! //! ### Custom error format //! -//! When using [TypedMultipart](crate::TypedMultipart) as an argument for your handlers, when the +//! When using [TypedMultipart](TypedMultipart) as an argument for your handlers, when the //! request is malformed, the error will be serialized as a string. If you would like to customize -//! the error format you can use the [BaseMultipart](crate::BaseMultipart) struct instead. This -//! struct is used internally by [TypedMultipart](crate::TypedMultipart) and it can be used to +//! the error format you can use the [BaseMultipart](BaseMultipart) struct instead. This +//! struct is used internally by [TypedMultipart](TypedMultipart) and it can be used to //! customize the error type. //! //! To customize the error you will need to define a custom error type and implement diff --git a/src/typed_multipart.rs b/src/typed_multipart.rs index 6de54da..977fa5d 100644 --- a/src/typed_multipart.rs +++ b/src/typed_multipart.rs @@ -3,7 +3,7 @@ use axum::async_trait; use axum::extract::{FromRequest, Request}; use std::ops::{Deref, DerefMut}; -/// Used as as an argument for axum [Handlers](axum::handler::Handler). +/// Used as an argument for axum [Handlers](axum::handler::Handler). /// /// Implements [FromRequest] when the generic argument implements the /// [TryFromMultipart] trait.