Skip to content

Commit

Permalink
Add conversion from stdlib Cow to our internal Cow.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobz committed Jan 24, 2021
1 parent e46c951 commit f4c0555
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
18 changes: 17 additions & 1 deletion metrics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- next-header -->

## [Unreleased] - ReleaseDate
### Added
- Added conversion from `std::borrow::Cow<'static, str>` for `SharedString`.

## [0.13.0] - 2021-01-22
### Added
- Support for specifying the unit of a measurement during registration. ([#107](https://github.com/metrics-rs/metrics/pull/107))
- New macros for registration: `register_counter!`, `register_gauge!`, `register_histogram!`.
- New macros for emission: `histogram!`, `increment_counter!`, `increment_gauge!`,
`decrement_gauge!`.
- Added unit support to describe the unit of a given metric.

### Removed
- Dropped the `timing!` and `value!` macros in favor of `histogram!`.

### Changed
- All macros are now procedural macros instead of declarative macros.
- Gauges are now `f64` instead of `i64`.
- Histograms are now `f64` instead of `u64`.
- `Key` now split into `Key` and `KeyData` to better support constant expression metric keys via
macro callsites.
- Significant overhaul of generated callsites via macros.

## [0.12.1] - 2019-11-21
### Changed
Expand Down
10 changes: 10 additions & 0 deletions metrics/src/cow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ where
}
}

impl From<std::borrow::Cow<'static, str>> for Cow<'_, str> {
#[inline]
fn from(s: std::borrow::Cow<'static, str>) -> Self {
match s {
std::borrow::Cow::Borrowed(bs) => Cow::borrowed(bs),
std::borrow::Cow::Owned(os) => Cow::owned(os),
}
}
}

impl From<String> for Cow<'_, str> {
#[inline]
fn from(s: String) -> Self {
Expand Down

0 comments on commit f4c0555

Please sign in to comment.