Skip to content

Commit ba1add0

Browse files
committed
Support meta in fields, fix docs and add examples
1 parent 98eafb9 commit ba1add0

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
All changes to this project will be noted in this file.
4+
5+
## Version 0.1.1
6+
7+
### Fixes
8+
9+
- Allow field attributes in `def!` macro
10+
- Added examples to repo
11+
- Fixed docs
12+
13+
## Version 0.1.0
14+
15+
Initial release

bagel/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "Apache-2.0"
77
name = "bagel"
88
readme = "../README.md"
99
repository = "https://github.com/skytable/bagel"
10-
version = "0.1.0"
10+
version = "0.1.1"
1111

1212
[dependencies]
1313
dough = "0.1.1"

bagel/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! - [`Ctor`]: Derive constructors
1010
//! - [`Gtor`]: Derive getters
1111
//! - [`Stor`]: Derive setters
12-
//! - [`def`]: Use the [default declaration syntax](https://github.com/skytable/bagel/README.md#default-declaration-syntax)
12+
//! - [`def`]: Use the [default declaration syntax](https://github.com/skytable/bagel#default-declaration-syntax)
1313
//!
1414
1515
#[macro_use]

bagel/src/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[macro_export]
2-
/// The [`def`] macro enables you to use the [default declaration syntax](https://github.com/skytable/bagel/README.md#default-declaration-syntax).
2+
/// The [`def`] macro enables you to use the [default declaration syntax](https://github.com/skytable/bagel#default-declaration-syntax).
33
///
44
/// ## Example
55
/// ```
@@ -33,12 +33,12 @@
3333
macro_rules! def {
3434
(
3535
$(#[$meta:meta])*
36-
$vis:vis struct $ident:ident {$($field:ident: $ty:ty $(= $expr:expr)?),*$(,)?}
36+
$vis:vis struct $ident:ident {$($(#[$fieldmeta:meta])*$field:ident: $ty:ty $(= $expr:expr)?),*$(,)?}
3737
) => {
3838
$(#[$meta])*
3939
$vis struct $ident {$($field: $ty,)*}
4040
impl ::core::default::Default for $ident {
41-
fn default() -> Self { Self {$($field: $crate::process_defexpr!($($expr)?),)*}}
41+
fn default() -> Self { Self {$($(#[$fieldmeta])* $field: $crate::process_defexpr!($($expr)?),)*}}
4242
}
4343
};
4444
}

examples/mixed.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use bagel::Gtor;
2+
3+
bagel::def! {
4+
#[derive(Gtor)]
5+
struct Hello {
6+
#[gtor_copy]
7+
a: u8 = 10,
8+
}
9+
}
10+
11+
fn main() {
12+
assert_eq!(Hello::default().get_a(), 10);
13+
}

0 commit comments

Comments
 (0)