提交 c048a07d authored 作者: Serhij S's avatar Serhij S

drop expired

上级 7c06a2ea
...@@ -44,6 +44,8 @@ where ...@@ -44,6 +44,8 @@ where
/// ///
/// Returns the value back if there is no capacity even after all [`DataDeliveryPolicy`] /// Returns the value back if there is no capacity even after all [`DataDeliveryPolicy`]
/// rules have been applied /// rules have been applied
///
/// Note: expired values are dropped and the operation returns: pushed=true
pub fn try_push(&mut self, value: T) -> TryPushOutput<T> { pub fn try_push(&mut self, value: T) -> TryPushOutput<T> {
macro_rules! push { macro_rules! push {
() => {{ () => {{
...@@ -57,6 +59,12 @@ where ...@@ -57,6 +59,12 @@ where
} }
}}; }};
} }
if value.is_expired() {
return TryPushOutput {
pushed: true,
value: None,
};
}
if value.is_delivery_policy_single() { if value.is_delivery_policy_single() {
self.data.retain(|d| !d.eq_kind(&value) && !d.is_expired()); self.data.retain(|d| !d.eq_kind(&value) && !d.is_expired());
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论