docs: update changelog

This commit is contained in:
Rob Ede 2025-02-09 21:47:14 +00:00
parent 15ce0c73f4
commit 4aab56dc01
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
3 changed files with 11 additions and 5 deletions

View File

@ -5,6 +5,7 @@
### Added
- Add `header::CLEAR_SITE_DATA` constant.
- Add `Extensions::get_or_insert[_with]()` methods.
### Changed

View File

@ -104,14 +104,17 @@ impl Extensions {
.and_then(|boxed| boxed.downcast_mut())
}
/// Get a mutable reference or insert an item of a given type.
/// Inserts the given `value` into the extensions if it is not present, then returns a reference
/// to the value in the extensions.
///
/// ```
/// use actix_http::Extensions;
/// # use actix_http::Extensions;
/// let mut map = Extensions::new();
/// assert_eq!(map.get::<Vec<u32>>(), None);
///
/// map.get_or_insert(Vec::<u32>::new()).push(1);
/// assert_eq!(map.get::<Vec<u32>>(), Some(&vec![1]));
///
/// map.get_or_insert(Vec::<u32>::new()).push(2);
/// assert_eq!(map.get::<Vec<u32>>(), Some(&vec![1,2]));
/// ```
@ -123,14 +126,17 @@ impl Extensions {
.expect("extensions map to always contain value T")
}
/// Get a mutable reference or insert an item of a given type calculated with the closure given.
/// Inserts a value computed from `f` into the extensions if the given `value` is not present,
/// then returns a reference to the value in the extensions.
///
/// ```
/// use actix_http::Extensions;
/// # use actix_http::Extensions;
/// let mut map = Extensions::new();
/// assert_eq!(map.get::<Vec<u32>>(), None);
///
/// map.get_or_insert_with(Vec::<u32>::new).push(1);
/// assert_eq!(map.get::<Vec<u32>>(), Some(&vec![1]));
///
/// map.get_or_insert_with(Vec::<u32>::new).push(2);
/// assert_eq!(map.get::<Vec<u32>>(), Some(&vec![1,2]));
/// ```

View File

@ -6,7 +6,6 @@
- On Windows, an error is now returned from `HttpServer::bind()` (or TLS variants) when binding to a socket that's already in use.
- Update `brotli` dependency to `7`.
- Minimum supported Rust version (MSRV) is now 1.75.
- Added `Extensions::get_or_insert` and `Extensions::get_or_insert_with`
## 4.9.0