mirror of
https://github.com/actix/actix-extras.git
synced 2024-12-18 01:33:59 +01:00
14 lines
418 B
Rust
14 lines
418 B
Rust
|
use std::borrow::Cow;
|
||
|
|
||
|
use bytes::{BufMut, BytesMut};
|
||
|
|
||
|
// `bytes::Buf` is not implemented for `Cow<'static, str>`, implementing it by ourselves.
|
||
|
#[inline]
|
||
|
#[allow(clippy::ptr_arg)] // Totally okay to accept the reference to Cow here
|
||
|
pub fn put_cow(buf: &mut BytesMut, value: &Cow<'static, str>) {
|
||
|
match value {
|
||
|
Cow::Borrowed(str) => buf.put(str),
|
||
|
Cow::Owned(ref string) => buf.put(string),
|
||
|
}
|
||
|
}
|