@@ -148,7 +148,8 @@ impl Hash for StreamAddress {
148
148
149
149
impl StreamAddress {
150
150
/// 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 ( ) ;
152
153
let mut parts = address. split ( ':' ) ;
153
154
154
155
let hostname = match parts. next ( ) {
@@ -776,16 +777,16 @@ impl ClientOptions {
776
777
/// Note: if the `sync` feature is enabled, then this method will be replaced with [the sync
777
778
/// version](#method.parse-1).
778
779
#[ cfg( not( feature = "sync" ) ) ]
779
- pub async fn parse ( s : & str ) -> Result < Self > {
780
+ pub async fn parse ( s : impl AsRef < str > ) -> Result < Self > {
780
781
Self :: parse_uri ( s, None ) . await
781
782
}
782
783
783
784
/// This method will be present if the `sync` feature is enabled. It's otherwise identical to
784
785
/// [the async version](#method.parse)
785
786
#[ cfg( any( feature = "sync" , docsrs) ) ]
786
787
#[ 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 ) )
789
790
}
790
791
791
792
/// Parses a MongoDB connection string into a `ClientOptions` struct.
@@ -804,7 +805,7 @@ impl ClientOptions {
804
805
/// version](#method.parse_with_resolver_config-1).
805
806
#[ cfg( not( feature = "sync" ) ) ]
806
807
pub async fn parse_with_resolver_config (
807
- uri : & str ,
808
+ uri : impl AsRef < str > ,
808
809
resolver_config : ResolverConfig ,
809
810
) -> Result < Self > {
810
811
Self :: parse_uri ( uri, Some ( resolver_config) ) . await
@@ -821,10 +822,10 @@ impl ClientOptions {
821
822
/// Populate this `ClientOptions` from the given URI, optionally using the resolver config for
822
823
/// DNS lookups.
823
824
pub ( crate ) async fn parse_uri (
824
- uri : & str ,
825
+ uri : impl AsRef < str > ,
825
826
resolver_config : Option < ResolverConfig > ,
826
827
) -> Result < Self > {
827
- let parser = ClientOptionsParser :: parse ( uri) ?;
828
+ let parser = ClientOptionsParser :: parse ( uri. as_ref ( ) ) ?;
828
829
let srv = parser. srv ;
829
830
let auth_source_present = parser. auth_source . is_some ( ) ;
830
831
let mut options: Self = parser. into ( ) ;
0 commit comments