Skip to content

feat: static_path macro for creating paths#239

Open
tewaro wants to merge 2 commits into
tewaro/freeze-unwindingfrom
tewaro/static_path
Open

feat: static_path macro for creating paths#239
tewaro wants to merge 2 commits into
tewaro/freeze-unwindingfrom
tewaro/static_path

Conversation

@tewaro

@tewaro tewaro commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Creates a path with a static lifetime so it can be used in ad-hoc oqueues for tracing.

@tewaro tewaro force-pushed the tewaro/static_path branch 2 times, most recently from 2be2ed5 to 8b02a77 Compare June 23, 2026 22:11
Comment thread ostd/src/orpc/path.rs
Creates a path with a static lifetime so it can be used in ad-hoc
oqueues for tracing.
@tewaro tewaro force-pushed the tewaro/static_path branch from 8b02a77 to 0ed98a3 Compare June 23, 2026 22:18
@tewaro tewaro marked this pull request as ready for review June 23, 2026 22:19
@tewaro tewaro requested a review from a team as a code owner June 23, 2026 22:19
Comment thread .gitignore Outdated
Comment thread ostd/src/orpc/path.rs
Comment thread ostd/src/orpc/path.rs
Comment on lines +446 to +451
#[ktest]
fn test_static_path_display() {
let path: &'static Path = static_path!(a.b[3].j);
assert_eq!(path.to_string(), "a.b[3].j");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't feel like copying all the tests is useful when the macro is a thin wrapper over another tested macro. Just a couple of tests that compare the two are enough. If there are any tests you think are specifically useful, that's fine. I just don't want to blindly copy them all. It just makes everything harder to follow and the goal of the tests less clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The tests are useful for future code iterations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not totally sure what you mean. The only difference is construction .to_string() will always call the exact same function regardless of if you use static_path! or path!. If you do want to run all the tests with both kinds of construction, maybe pull asserts out into another function and call it on the different paths. That way we can also be sure the semantics of the two kinds of path are always the same. (This is definitely reasonable since as you say we maybe changing the internal representation a bit to support both static and dynamic strings.)

@arthurp arthurp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is great.

Not merging this until we get the big merge in would make things marginally easier for me. But since it shouldn't conflict, the machinations required to move the merge up one on main isn't a big problem.

Comment thread ostd/src/orpc/path.rs
}};
}

/// Similar to path! Creates a new [`Path`] from `.` delimited literal using static storage.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please document that interpolation is not allowed. It's impossible to implement, but people may not intuit that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

what is interpolation sorry?

Comment thread ostd/src/orpc/path.rs Outdated

/// A path whose components are stored in owned heap memory.
#[derive(Debug, Clone)]
pub struct OwnedPath {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I kinda think this shouldn't be pub. No one should write code that REQUIRES the use of an owned path. What's your take?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that's fair.

@tewaro tewaro force-pushed the tewaro/static_path branch 2 times, most recently from fc14b76 to 531876e Compare June 25, 2026 22:46
@tewaro tewaro force-pushed the tewaro/static_path branch from 531876e to a675fba Compare June 25, 2026 22:48
@arthurp

arthurp commented Jun 26, 2026 via email

Copy link
Copy Markdown
Contributor

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