Skip to content

Commit 9ec3cc0

Browse files
Replace str_split_once to lower actix-tls msrv to 1.50.0 and bump actix-net to 1.50.0 (#434)
1 parent 01e0f92 commit 9ec3cc0

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

actix-tls/CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changes
22

33
## Unreleased - 2021-xx-xx
4-
4+
- Remove use of `str::split_once` to lower MSRV of `actix-tls` to a de-facto 1.50.0 from 1.52.0
55

66
## 3.0.0 - 2021-12-26
77
* No significant changes since `3.0.0-rc.2`.

actix-tls/src/connect/host.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ pub trait Host: Unpin + 'static {
2727

2828
impl Host for String {
2929
fn hostname(&self) -> &str {
30-
self.split_once(':')
30+
str_split_once(self, ':')
3131
.map(|(hostname, _)| hostname)
3232
.unwrap_or(self)
3333
}
3434

3535
fn port(&self) -> Option<u16> {
36-
self.split_once(':').and_then(|(_, port)| port.parse().ok())
36+
str_split_once(self, ':').and_then(|(_, port)| port.parse().ok())
3737
}
3838
}
3939

4040
impl Host for &'static str {
4141
fn hostname(&self) -> &str {
42-
self.split_once(':')
42+
str_split_once(self, ':')
4343
.map(|(hostname, _)| hostname)
4444
.unwrap_or(self)
4545
}
4646

4747
fn port(&self) -> Option<u16> {
48-
self.split_once(':').and_then(|(_, port)| port.parse().ok())
48+
str_split_once(self, ':').and_then(|(_, port)| port.parse().ok())
4949
}
5050
}
5151

@@ -69,3 +69,11 @@ mod tests {
6969
assert_connection_info_eq!("example.com:false:false", "example.com", None);
7070
}
7171
}
72+
73+
// `str::split_once` is stabilized in 1.52.0
74+
fn str_split_once(str: &str, delimiter: char) -> Option<(&str, &str)> {
75+
let mut splitn = str.splitn(2, delimiter);
76+
let prefix = splitn.next()?;
77+
let suffix = splitn.next()?;
78+
Some((prefix, suffix))
79+
}

0 commit comments

Comments
 (0)