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

Enforce static lifetime for instrumentation functions #18

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

cstyles
Copy link
Contributor

@cstyles cstyles commented Feb 28, 2025

We only ever provide static string slices to these functions. We can enforce that in the function signatures and save ourselves an allocation.


This change is Reviewable

We only ever provide static string slices to these functions. We can
enforce that in the function signatures and save ourselves an
allocation.
Copy link
Contributor

@lilymara-onesignal lilymara-onesignal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @cstyles)


src/experiment.rs line 38 at r1 (raw file):

}

async fn instrument_control<F, T>(name: &'static str, future: F) -> T

Can we do impl Into<Cow<'static, str>> to allow for the possibility of dynamic names?

Copy link
Contributor Author

@cstyles cstyles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @lilymara-onesignal)


src/experiment.rs line 38 at r1 (raw file):

Previously, lilymara-onesignal (Lily Mara) wrote…

Can we do impl Into<Cow<'static, str>> to allow for the possibility of dynamic names?

We can, although we only ever call these functions with the name field which has to be a &'static str per the constructor:

pub fn new(name: &'static str) -> Self {

Would you like me to update the constructor as well?

Copy link
Contributor

@lilymara-onesignal lilymara-onesignal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @cstyles)


src/experiment.rs line 38 at r1 (raw file):

Previously, cstyles (Collin Styles) wrote…

We can, although we only ever call these functions with the name field which has to be a &'static str per the constructor:

pub fn new(name: &'static str) -> Self {

Would you like me to update the constructor as well?

Ahh ok, maybe then this is not necessary. Let's leave as &'static str

@cstyles cstyles merged commit 6ec8838 into main Mar 4, 2025
1 check passed
@cstyles cstyles deleted the enforce-static-str branch March 4, 2025 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants