Skip to content

Commit f8517a2

Browse files
committed
mime: add as_str() to ParamName and ParamValue
Previously, there was no way to actually get the string values.
1 parent 5396382 commit f8517a2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/mime/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ impl ToHeaderValues for Mime {
154154
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
155155
pub struct ParamName(Cow<'static, str>);
156156

157+
impl ParamName {
158+
/// Get the name as a `&str`
159+
pub fn as_str(&self) -> &str {
160+
&self.0
161+
}
162+
}
163+
157164
impl Display for ParamName {
158165
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
159166
Display::fmt(&self.0, f)
@@ -182,6 +189,13 @@ impl<'a> From<&'a str> for ParamName {
182189
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
183190
pub struct ParamValue(Cow<'static, str>);
184191

192+
impl ParamValue {
193+
/// Get the value as a `&str`
194+
pub fn as_str(&self) -> &str {
195+
&self.0
196+
}
197+
}
198+
185199
impl Display for ParamValue {
186200
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
187201
Display::fmt(&self.0, f)

0 commit comments

Comments
 (0)