mirror of https://github.com/fafhrd91/actix-net
				
				
				
			replace str_split_once to lower msrv to 1.50.0
This commit is contained in:
		
							parent
							
								
									01e0f922de
								
							
						
					
					
						commit
						d655083ef8
					
				|  | @ -13,7 +13,7 @@ See `actix-server/examples` and `actix-tls/examples` for some basic examples. | ||||||
| 
 | 
 | ||||||
| ### MSRV | ### MSRV | ||||||
| 
 | 
 | ||||||
| This repo's Minimum Supported Rust Version (MSRV) is 1.46.0. | This repo's Minimum Supported Rust Version (MSRV) is 1.50.0. | ||||||
| 
 | 
 | ||||||
| ## License | ## License | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| # Changes | # Changes | ||||||
| 
 | 
 | ||||||
| ## Unreleased - 2021-xx-xx | ## Unreleased - 2021-xx-xx | ||||||
| 
 | - Remove use of `str::split_once` to lower MSRV to 1.50.0 and update the README to correctly report that | ||||||
| 
 | 
 | ||||||
| ## 3.0.0 - 2021-12-26 | ## 3.0.0 - 2021-12-26 | ||||||
| * No significant changes since `3.0.0-rc.2`. | * No significant changes since `3.0.0-rc.2`. | ||||||
|  |  | ||||||
|  | @ -27,25 +27,25 @@ pub trait Host: Unpin + 'static { | ||||||
| 
 | 
 | ||||||
| impl Host for String { | impl Host for String { | ||||||
|     fn hostname(&self) -> &str { |     fn hostname(&self) -> &str { | ||||||
|         self.split_once(':') |         str_split_once(self, ':') | ||||||
|             .map(|(hostname, _)| hostname) |             .map(|(hostname, _)| hostname) | ||||||
|             .unwrap_or(self) |             .unwrap_or(self) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn port(&self) -> Option<u16> { |     fn port(&self) -> Option<u16> { | ||||||
|         self.split_once(':').and_then(|(_, port)| port.parse().ok()) |         str_split_once(self, ':').and_then(|(_, port)| port.parse().ok()) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Host for &'static str { | impl Host for &'static str { | ||||||
|     fn hostname(&self) -> &str { |     fn hostname(&self) -> &str { | ||||||
|         self.split_once(':') |         str_split_once(self, ':') | ||||||
|             .map(|(hostname, _)| hostname) |             .map(|(hostname, _)| hostname) | ||||||
|             .unwrap_or(self) |             .unwrap_or(self) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn port(&self) -> Option<u16> { |     fn port(&self) -> Option<u16> { | ||||||
|         self.split_once(':').and_then(|(_, port)| port.parse().ok()) |         str_split_once(self, ':').and_then(|(_, port)| port.parse().ok()) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -69,3 +69,11 @@ mod tests { | ||||||
|         assert_connection_info_eq!("example.com:false:false", "example.com", None); |         assert_connection_info_eq!("example.com:false:false", "example.com", None); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | // `str::split_once` is stabilized in 1.52.0
 | ||||||
|  | fn str_split_once(str: &str, delimiter: char) -> Option<(&str, &str)> { | ||||||
|  |     let mut splitn = str.splitn(2, delimiter); | ||||||
|  |     let prefix = splitn.next()?; | ||||||
|  |     let suffix = splitn.next()?; | ||||||
|  |     Some((prefix, suffix)) | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue