diff options
| author | bors <bors@rust-lang.org> | 2022-05-21 19:49:51 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-21 19:49:51 +0000 |
| commit | 9257f5aad02b65665a6e23e5b92938548302e129 (patch) | |
| tree | af052cd62b50d1fb6a39b3146712cb5e2a5f09d1 /compiler/rustc_codegen_llvm/src | |
| parent | bb4781aa277b6746e6f072252ddad95c59e94fd1 (diff) | |
| parent | a8acfa89864a4c1f479d81e3effa3a7101e7c39a (diff) | |
| download | rust-9257f5aad02b65665a6e23e5b92938548302e129.tar.gz rust-9257f5aad02b65665a6e23e5b92938548302e129.zip | |
Auto merge of #94530 - tmiasko:alignment-impls, r=dtolnay
Implement Copy, Clone, PartialEq and Eq for core::fmt::Alignment
Alignment is a fieldless exhaustive enum, so it is already possible to
clone and compare it by matching, but it is inconvenient to do so. For
example, if one would like to create a struct describing a formatter
configuration and provide a clone implementation:
```rust
pub struct Format {
fill: char,
width: Option<usize>,
align: fmt::Alignment,
}
impl Clone for Format {
fn clone(&self) -> Self {
Format {
align: match self.align {
fmt::Alignment::Left => fmt::Alignment::Left,
fmt::Alignment::Right => fmt::Alignment::Right,
fmt::Alignment::Center => fmt::Alignment::Center,
},
.. *self
}
}
}
```
Derive Copy, Clone, PartialEq, and Eq for Alignment for convenience.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions
