@@ -211,9 +211,9 @@ pub struct HumanReadableName {
211211impl HumanReadableName {
212212/// Constructs a new [`HumanReadableName`] from the `user` and `domain` parts. See the
213213/// struct-level documentation for more on the requirements on each.
214- pub fn new ( user : & str , domain : & str ) -> Result < HumanReadableName , ( ) > {
214+ pub fn new ( user : & str , domain : & str ) -> Result < Self , ( ) > {
215215// First normalize domain and remove the optional trailing `.`
216- let domain = domain. strip_suffix ( "." ) . unwrap_or ( domain) ;
216+ let domain = domain. strip_suffix ( '.' ) . unwrap_or ( domain) ;
217217if user. len ( ) + domain. len ( ) + REQUIRED_EXTRA_LEN > 255 {
218218return Err ( ( ) ) ;
219219}
@@ -233,24 +233,17 @@ impl HumanReadableName {
233233let mut contents = [ 0 ; 255 - REQUIRED_EXTRA_LEN ] ;
234234contents[ ..user. len ( ) ] . copy_from_slice ( user. as_bytes ( ) ) ;
235235contents[ user. len ( ) ..user. len ( ) + domain. len ( ) ] . copy_from_slice ( domain. as_bytes ( ) ) ;
236- Ok ( HumanReadableName {
237- contents,
238- user_len : user. len ( ) as u8 ,
239- domain_len : domain. len ( ) as u8 ,
240- } )
236+ Ok ( Self { contents, user_len : user. len ( ) as u8 , domain_len : domain. len ( ) as u8 } )
241237}
242238
243239/// Constructs a new [`HumanReadableName`] from the standard encoding - `user`@`domain`.
244240///
245241/// If `user` includes the standard BIP 353 ₿ prefix it is automatically removed as required by
246242/// BIP 353.
247- pub fn from_encoded ( encoded : & str ) -> Result < HumanReadableName , ( ) > {
248- if let Some ( ( user, domain) ) = encoded. strip_prefix ( '₿' ) . unwrap_or ( encoded) . split_once ( "@" )
249- {
250- Self :: new ( user, domain)
251- } else {
252- Err ( ( ) )
253- }
243+ pub fn from_encoded ( encoded : & str ) -> Result < Self , ( ) > {
244+ let encoded = encoded. strip_prefix ( '₿' ) . unwrap_or ( encoded) ;
245+ let ( user, domain) = encoded. split_once ( '@' ) . ok_or ( ( ) ) ?;
246+ Self :: new ( user, domain)
254247}
255248
256249/// Gets the `user` part of this Human Readable Name
@@ -438,9 +431,9 @@ impl OMNameResolver {
438431& self , msg : DNSSECProof , context : DNSResolverContext ,
439432) -> Option < ( Vec < ( HumanReadableName , PaymentId ) > , Offer ) > {
440433let ( completed_requests, uri) = self . handle_dnssec_proof_for_uri ( msg, context) ?;
441- if let Some ( ( _onchain, params) ) = uri. split_once ( "?" ) {
442- for param in params. split ( "&" ) {
443- let ( k, v) = if let Some ( split) = param. split_once ( "=" ) {
434+ if let Some ( ( _onchain, params) ) = uri. split_once ( '?' ) {
435+ for param in params. split ( '&' ) {
436+ let ( k, v) = if let Some ( split) = param. split_once ( '=' ) {
444437split
445438} else {
446439continue ;
0 commit comments