Skip to content

Commit 602fa40

Browse files
committed
feat: v1.13.4
1 parent 829bf33 commit 602fa40

File tree

12 files changed

+184
-119
lines changed

12 files changed

+184
-119
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "lombok-macros"
3-
version = "1.13.3"
3+
version = "1.13.4"
44
edition = "2024"
55
authors = ["root@ltpp.vip"]
66
license = "MIT"
7-
description = """A collection of procedural macros for Lombok-like functionality in Rust."""
7+
description = """A Rust procedural macro collection providing Lombok-like functionality. Automatically generates getters/setters with field-level visibility control, custom Debug implementations with field skipping, and Display trait implementations. Supports structs, enums, generics and lifetimes."""
88
keywords = ["proc-macro", "get-set", "macros", "lombok", "code-generation"]
99
repository = "https://github.com/eastspire/lombok-macros.git"
1010
categories = ["development-tools"]

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
[Api Docs](https://docs.rs/lombok-macros/latest/lombok_macros/)
1616

17-
> A collection of procedural macros for Lombok-like functionality in Rust.
17+
> A Rust procedural macro collection providing Lombok-like functionality. Automatically generates getters/setters with field-level visibility control, custom Debug implementations with field skipping, and Display trait implementations. Supports structs, enums, generics and lifetimes.
1818
1919
## Installation
2020

src/cfg/impl.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
use crate::*;
22

3+
/// Provides default configuration values for the Cfg struct.
34
impl Default for Cfg {
5+
/// Returns a default `Cfg` instance with unknown function type, skip set to false, and public visibility.
6+
///
7+
/// # Returns
8+
///
9+
/// - `Cfg` - A new `Cfg` instance with default values.
410
fn default() -> Self {
511
Self {
612
func_type: FuncType::Unknown,

src/cfg/struct.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ use crate::{func::*, visibility::*};
1111
/// - `visibility`: A `Visibility` that defines the visibility of the function (e.g., `Public`, `Private`).
1212
#[derive(Debug, Clone, PartialEq, Eq)]
1313
pub struct Cfg {
14+
/// A `FuncType` that specifies the function type (e.g., `Get`, `Set`, or `Unknown`).
1415
pub(crate) func_type: FuncType,
16+
/// A boolean flag indicating whether the function should be skipped during processing.
1517
pub(crate) skip: bool,
18+
/// A `Visibility` that defines the visibility of the function (e.g., `Public`, `Private`).
1619
pub(crate) visibility: Visibility,
1720
}

src/func/enum.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22
///
33
/// # Variants
44
/// - `Get`: Represents a getter function.
5+
/// - `GetMut`: Represents a mutable getter function.
56
/// - `Set`: Represents a setter function.
67
/// - `Debug`: Represents a debug function.
78
/// - `Unknown`: Represents an unknown or unspecified function type.
89
#[derive(Debug, Clone, PartialEq, Eq)]
910
pub enum FuncType {
11+
/// Represents a getter function.
1012
Get,
13+
/// Represents a mutable getter function.
1114
GetMut,
15+
/// Represents a setter function.
1216
Set,
17+
/// Represents a debug function.
1318
Debug,
19+
/// Represents an unknown or unspecified function type.
1420
Unknown,
1521
}

src/func/impl.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
use crate::*;
22

3+
/// Provides default implementation for FuncType.
34
impl Default for FuncType {
5+
/// Returns the default value for FuncType, which is Unknown.
46
fn default() -> Self {
57
Self::Unknown
68
}
79
}
810

11+
/// Implements the `FromStr` trait for `FuncType` to parse string representations into `FuncType` variants.
912
impl FromStr for FuncType {
1013
type Err = String;
1114

15+
/// Parses a string slice into a `FuncType`.
16+
///
17+
/// # Arguments
18+
///
19+
/// - `s`: The string slice to parse.
20+
///
21+
/// # Returns
22+
///
23+
/// - `Result<FuncType, String>`: Ok containing the `FuncType` if parsing is successful,
24+
/// or an Err containing a String error message if parsing fails.
1225
fn from_str(s: &str) -> Result<FuncType, std::string::String> {
1326
match s {
1427
GET => Ok(FuncType::Get),
@@ -24,7 +37,7 @@ impl FuncType {
2437
/// Checks if the `FuncType` is `Get`.
2538
///
2639
/// # Parameters
27-
/// - `self`: The reference to the `FuncType` instance.
40+
/// - `self` - The reference to the `FuncType` instance.
2841
///
2942
/// # Returns
3043
/// - `true` if the `FuncType` is `Get`; otherwise, `false`.
@@ -35,7 +48,7 @@ impl FuncType {
3548
/// Checks if the `FuncType` is `GetMut`.
3649
///
3750
/// # Parameters
38-
/// - `self`: The reference to the `FuncType` instance.
51+
/// - `self` - The reference to the `FuncType` instance.
3952
///
4053
/// # Returns
4154
/// - `true` if the `FuncType` is `GetMut`; otherwise, `false`.
@@ -46,7 +59,7 @@ impl FuncType {
4659
/// Checks if the `FuncType` is `Set`.
4760
///
4861
/// # Parameters
49-
/// - `self`: The reference to the `FuncType` instance.
62+
/// - `self` - The reference to the `FuncType` instance.
5063
///
5164
/// # Returns
5265
/// - `true` if the `FuncType` is `Set`; otherwise, `false`.
@@ -57,7 +70,7 @@ impl FuncType {
5770
/// Checks if the `FuncType` is `Debug`.
5871
///
5972
/// # Parameters
60-
/// - `self`: The reference to the `FuncType` instance.
73+
/// - `self` - The reference to the `FuncType` instance.
6174
///
6275
/// # Returns
6376
/// - `true` if the `FuncType` is `Debug`; otherwise, `false`.
@@ -68,7 +81,7 @@ impl FuncType {
6881
/// Checks if the `FuncType` is `Unknown`.
6982
///
7083
/// # Parameters
71-
/// - `self`: The reference to the `FuncType` instance.
84+
/// - `self` - The reference to the `FuncType` instance.
7285
///
7386
/// # Returns
7487
/// - `true` if the `FuncType` is `Unknown`; otherwise, `false`.
@@ -79,10 +92,10 @@ impl FuncType {
7992
/// Checks if the `FuncType` is `Unknown`.
8093
///
8194
/// # Parameters
82-
/// - `self`: The reference to the `FuncType` instance.
95+
/// - `func_type_str`: The string slice representing the function type to check.
8396
///
8497
/// # Returns
85-
/// - `true` if the `FuncType` is `Unknown`; otherwise, `false`.
98+
/// - `true` if the `FuncType` parsed from the string is not `Unknown`; otherwise, `false`.
8699
pub fn is_known(func_type_str: &str) -> bool {
87100
let func_type: FuncType = func_type_str.parse::<FuncType>().unwrap_or_default();
88101
func_type != Self::Unknown

src/generate/const.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
/// Error message indicating that a field must have a name.
12
pub const FIELD_SHOULD_HAVE_A_NAME: &str = "Field should have a name";
3+
/// Prefix for getter methods.
24
pub const GET_METHOD_PREFIX: &str = "get_";
5+
/// Prefix for mutable getter methods.
36
pub const GET_MUT_METHOD_PREFIX: &str = "get_mut_";
7+
/// Prefix for setter methods.
48
pub const SET_METHOD_PREFIX: &str = "set_";
9+
/// Error message indicating that #[derive(Lombok)] is only supported for structs.
510
pub const UNSUPPORTED_LOMBOK_DERIVE: &str = "#[derive(Lombok)] is only supported for structs.";

0 commit comments

Comments
 (0)