@@ -148,7 +148,8 @@ impl Hash for StreamAddress {
148148
149149impl StreamAddress {
150150 /// Parses an address string into a `StreamAddress`.
151- pub fn parse ( address : & str ) -> Result < Self > {
151+ pub fn parse ( address : impl AsRef < str > ) -> Result < Self > {
152+ let address = address. as_ref ( ) ;
152153 let mut parts = address. split ( ':' ) ;
153154
154155 let hostname = match parts. next ( ) {
@@ -776,16 +777,16 @@ impl ClientOptions {
776777 /// Note: if the `sync` feature is enabled, then this method will be replaced with [the sync
777778 /// version](#method.parse-1).
778779 #[ cfg( not( feature = "sync" ) ) ]
779- pub async fn parse ( s : & str ) -> Result < Self > {
780+ pub async fn parse ( s : impl AsRef < str > ) -> Result < Self > {
780781 Self :: parse_uri ( s, None ) . await
781782 }
782783
783784 /// This method will be present if the `sync` feature is enabled. It's otherwise identical to
784785 /// [the async version](#method.parse)
785786 #[ cfg( any( feature = "sync" , docsrs) ) ]
786787 #[ cfg_attr( docsrs, doc( cfg( feature = "sync" ) ) ) ]
787- pub fn parse ( s : & str ) -> Result < Self > {
788- crate :: RUNTIME . block_on ( Self :: parse_uri ( s, None ) )
788+ pub fn parse ( s : impl AsRef < str > ) -> Result < Self > {
789+ crate :: RUNTIME . block_on ( Self :: parse_uri ( s. as_ref ( ) , None ) )
789790 }
790791
791792 /// Parses a MongoDB connection string into a `ClientOptions` struct.
@@ -804,7 +805,7 @@ impl ClientOptions {
804805 /// version](#method.parse_with_resolver_config-1).
805806 #[ cfg( not( feature = "sync" ) ) ]
806807 pub async fn parse_with_resolver_config (
807- uri : & str ,
808+ uri : impl AsRef < str > ,
808809 resolver_config : ResolverConfig ,
809810 ) -> Result < Self > {
810811 Self :: parse_uri ( uri, Some ( resolver_config) ) . await
@@ -821,10 +822,10 @@ impl ClientOptions {
821822 /// Populate this `ClientOptions` from the given URI, optionally using the resolver config for
822823 /// DNS lookups.
823824 pub ( crate ) async fn parse_uri (
824- uri : & str ,
825+ uri : impl AsRef < str > ,
825826 resolver_config : Option < ResolverConfig > ,
826827 ) -> Result < Self > {
827- let parser = ClientOptionsParser :: parse ( uri) ?;
828+ let parser = ClientOptionsParser :: parse ( uri. as_ref ( ) ) ?;
828829 let srv = parser. srv ;
829830 let auth_source_present = parser. auth_source . is_some ( ) ;
830831 let mut options: Self = parser. into ( ) ;
0 commit comments