Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ink: refactor AsOption lifetimes
  • Loading branch information
davidsemakula committed Sep 9, 2025
commit a7a82488200727ae6f57ee997d66b8cdfef4496a
14 changes: 7 additions & 7 deletions crates/ink/src/option_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@

pub struct AsOption<'lt, T>(pub &'lt T);

impl<T> AsOption<'_, ::core::option::Option<T>> {
impl<'lt, T> AsOption<'lt, ::core::option::Option<T>> {
#[inline]
// We need to allow for dead code at this point because
// the Rust compiler thinks this function is unused even
// though it acts as the specialized case for detection.
#[allow(dead_code)]
pub fn value(&self) -> Option<&T> {
pub fn value(&self) -> Option<&'lt T> {
self.0.as_ref()
}
}

impl<'lt, T> AsOption<'lt, &'lt ::core::option::Option<T>> {
#[inline]
pub fn value(&self) -> Option<&T> {
pub fn value(&self) -> Option<&'lt T> {
self.0.as_ref()
}
}

pub trait AsOptionFallback<T> {
fn value(&self) -> Option<&T>;
pub trait AsOptionFallback<'lt, T> {
fn value(&self) -> Option<&'lt T>;
}
impl<T> AsOptionFallback<T> for AsOption<'_, T> {
impl<'lt, T> AsOptionFallback<'lt, T> for AsOption<'lt, T> {
#[inline]
fn value(&self) -> Option<&T> {
fn value(&self) -> Option<&'lt T> {
Some(self.0)
}
}
Expand Down