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

Rename WasiState::new() to WasiState::builder() #3471

Merged
merged 4 commits into from
Jan 16, 2023
Merged

Conversation

Michael-F-Bryan
Copy link
Contributor

The typical convention is for Foo::new() to return an instance of Foo and Foo::builder() to return some type of builder object. Our WasiState type doesn't follow this convention (and explicitly #[allow]s the associated clippy warning), so the API can be confusing for anyone that hasn't used it before.

I've renamed the WasiState::new() function to WasiState::builder() and added a #[deprecated] attribute to the original WasiState::new() so it doesn't break Deploy.

@Michael-F-Bryan Michael-F-Bryan added the lib-wasix Issues related to the WASIX toolchain. label Jan 10, 2023
Copy link
Contributor

@theduke theduke left a comment

Choose a reason for hiding this comment

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

Small additional change, then good to go.

@@ -264,7 +264,14 @@ impl WasiState {
/// Create a [`WasiStateBuilder`] to construct a validated instance of
/// [`WasiState`].
#[allow(clippy::new_ret_no_self)]
#[deprecated = "Use WasiState::builder()"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#[deprecated = "Use WasiState::builder()"]
#[deprecated(note = "Use WasiState::builder() instead", since = "3.2.0"]


/// Create a [`WasiStateBuilder`] to construct a validated instance of
/// [`WasiState`].
pub fn builder(program_name: impl AsRef<str>) -> WasiStateBuilder {
create_wasi_state(program_name.as_ref())
Copy link
Contributor

Choose a reason for hiding this comment

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

While you are it it, can you do: create_wasi_state() -> WasiStateBuilder::new()?

Copy link
Contributor

@theduke theduke left a comment

Choose a reason for hiding this comment

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

LGTM

Do we have a solution for the nasty CI issues?

@Michael-F-Bryan
Copy link
Contributor Author

@theduke it looks like the CI issues are coming from the wasix branch itself and not related to this PR.

@theduke theduke merged commit bc18e5d into wasix Jan 16, 2023
@theduke theduke deleted the rename-wasistate-new branch January 16, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib-wasix Issues related to the WASIX toolchain.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants