1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::{Strong, StrongBuf, Validator};
use std::{convert::TryFrom, str::FromStr};
impl<Ctx> TryFrom<String> for StrongBuf<Ctx>
where
Ctx: Validator
{
type Error = Ctx::Err;
fn try_from(s: String) -> Result<Self, Self::Error> { Self::validate(s) }
}
impl<'a, Ctx> TryFrom<&'a str> for &'a Strong<Ctx>
where
Ctx: Validator
{
type Error = Ctx::Err;
fn try_from(s: &'a str) -> Result<Self, Self::Error> { Strong::validate(s) }
}
impl<Ctx> FromStr for StrongBuf<Ctx>
where
Ctx: Validator
{
type Err = Ctx::Err;
fn from_str(s: &str) -> Result<Self, Self::Err> { Self::validate(s.to_string()) }
}
impl<Ctx> AsRef<Strong<Ctx>> for StrongBuf<Ctx>
where
Ctx: Validator
{
fn as_ref(&self) -> &Strong<Ctx> { self }
}