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

Fix #961: Change Forth stack return type to slice #1032

Merged
merged 1 commit into from
Nov 20, 2020
Merged

Fix #961: Change Forth stack return type to slice #1032

merged 1 commit into from
Nov 20, 2020

Conversation

PaulDance
Copy link
Contributor

Closes #961: as discussed, this adjusts the return type to &[Value] in order to reduce the amount of cloning required and since it is used for tests only, it does not truly break the type's API.

Closes #961: returning an owned value for a getter that is used for
tests only is a bit silly, so this changes the return type of the
`Forth::stack` method from `Vec<Value>` to `&[Value]`. It does not
require changing the tests.

Signed-off-by: Paul Mabileau <[email protected]>
Copy link
Member

@coriolinus coriolinus left a comment

Choose a reason for hiding this comment

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

Haha, I'd imagined it would be a bigger change than that!

@coriolinus coriolinus merged commit 29f67a3 into exercism:master Nov 20, 2020
@PaulDance PaulDance deleted the simpler-forth branch November 20, 2020 15:16
@PaulDance
Copy link
Contributor Author

Me too 😄!

@coriolinus
Copy link
Member

Actually, I shouldn't have merged quite that quickly. Would you please update example.rs as well, as a demonstration that the tests don't need changing? It'll need to be in a new PR, but it's better to be able to show for sure that the new API works.

@PaulDance
Copy link
Contributor Author

Okay, I'll get on it then!

@PaulDance
Copy link
Contributor Author

Wait, actually @coriolinus, the stack used in the example surprisingly is a LinkedList instead of a Vec so borrowing a slice is impossible... Should we try to refactor the example in order to use a vector instead?

@coriolinus
Copy link
Member

coriolinus commented Nov 20, 2020 via email

@PaulDance
Copy link
Contributor Author

Okay, I just didn't know if it was something we could consider ¯\_(°^°)_/¯

coriolinus pushed a commit that referenced this pull request Nov 20, 2020
As discussed in #1032, the PR was merged too quickly, so this is to
complete the contribution by updating the exercise's example in order to
be compatible with the modified unit tests.

Signed-off-by: Paul Mabileau <[email protected]>
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.

Unidiomatic API in forth
2 participants