| 1 |
--- |
| 2 |
title: "`CustomAttributes::with_attribute` has been replaced by a builder" |
| 3 |
pull_requests: [24171] |
| 4 |
--- |
| 5 |
|
| 6 |
Previously, `CustomAttributes` were created like this: |
| 7 |
|
| 8 |
```rust |
| 9 |
let custom_attributes = CustomAttributes::default() |
| 10 |
.with_attribute("my attribute"); |
| 11 |
.with_attribute(123); |
| 12 |
``` |
| 13 |
|
| 14 |
Now, `CustomAttributes` are created with `CustomAttributesBuilder`: |
| 15 |
|
| 16 |
```rust |
| 17 |
let custom_attributes = CustomAttributesBuilder::new() |
| 18 |
.attribute("my attribute") |
| 19 |
.attribute(123) |
| 20 |
.build(); |
| 21 |
``` |
| 22 |
|
| 23 |
This change was a side effect of memory optimizations internal to |
| 24 |
`CustomAttributes`. |