Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify lifetime uses in data/literal binary operators #495

Merged
merged 1 commit into from
Mar 12, 2022
Merged
Changes from all commits
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
10 changes: 5 additions & 5 deletions core/src/data/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<'a> Literal<'a> {
}
}

pub fn add<'b>(&self, other: &Literal<'a>) -> Result<Literal<'b>> {
pub fn add(&self, other: &Literal<'a>) -> Result<Literal<'static>> {
match (self, other) {
(Number(l), Number(r)) => Ok(Number(Cow::Owned(l.as_ref() + r.as_ref()))),
(Interval(l), Interval(r)) => l.add(r).map(Interval),
Expand All @@ -150,7 +150,7 @@ impl<'a> Literal<'a> {
}
}

pub fn subtract<'b>(&self, other: &Literal<'a>) -> Result<Literal<'b>> {
pub fn subtract(&self, other: &Literal<'a>) -> Result<Literal<'static>> {
match (self, other) {
(Number(l), Number(r)) => Ok(Number(Cow::Owned(l.as_ref() - r.as_ref()))),
(Interval(l), Interval(r)) => l.subtract(r).map(Interval),
Expand All @@ -167,7 +167,7 @@ impl<'a> Literal<'a> {
}
}

pub fn multiply<'b>(&self, other: &Literal<'a>) -> Result<Literal<'b>> {
pub fn multiply(&self, other: &Literal<'a>) -> Result<Literal<'static>> {
match (self, other) {
(Number(l), Number(r)) => Ok(Number(Cow::Owned(l.as_ref() * r.as_ref()))),
(Number(l), Interval(r)) | (Interval(r), Number(l)) => {
Expand All @@ -192,7 +192,7 @@ impl<'a> Literal<'a> {
}
}

pub fn divide<'b>(&self, other: &Literal<'a>) -> Result<Literal<'b>> {
pub fn divide(&self, other: &Literal<'a>) -> Result<Literal<'static>> {
match (self, other) {
(Number(l), Number(r)) => {
if *r.as_ref() == 0.into() {
Expand Down Expand Up @@ -224,7 +224,7 @@ impl<'a> Literal<'a> {
}
}

pub fn modulo<'b>(&self, other: &Literal<'a>) -> Result<Literal<'b>> {
pub fn modulo(&self, other: &Literal<'a>) -> Result<Literal<'static>> {
match (self, other) {
(Number(l), Number(r)) => {
if *r.as_ref() == 0.into() {
Expand Down