Skip to content

Commit 67c967a

Browse files
committed
NgxStr::to_str renamed as_str
In Rust, the convention is that `to_` methods take ownership of self (e.g. fn to_string(self) -> Self) whereas `as_` methods borrow self (e.g. fn as_str(&self) -> &str).
1 parent 65fbe77 commit 67c967a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

examples/awssig.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ http_request_handler!(awssigv4_header_handler, |request: &mut Request| {
282282
}
283283

284284
let datetime = chrono::Utc::now();
285-
let uri = match request.unparsed_uri().to_str() {
285+
let uri = match request.unparsed_uri().as_str() {
286286
Ok(v) => format!("https://{}.{}{}", conf.s3_bucket, conf.s3_endpoint, v),
287287
Err(_) => return core::Status::NGX_DECLINED,
288288
};

src/core/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl NgxStr {
6868
}
6969

7070
/// Yields a `&str` slice if the [`NgxStr`] contains valid UTF-8.
71-
pub fn to_str(&self) -> Result<&str, Utf8Error> {
71+
pub fn as_str(&self) -> Result<&str, Utf8Error> {
7272
str::from_utf8(self.as_bytes())
7373
}
7474

0 commit comments

Comments
 (0)