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

rust: support cloning Modules #719

Merged
merged 1 commit into from
Feb 5, 2021
Merged

rust: support cloning Modules #719

merged 1 commit into from
Feb 5, 2021

Conversation

axic
Copy link
Member

@axic axic commented Feb 4, 2021

No description provided.

@codecov
Copy link

codecov bot commented Feb 4, 2021

Codecov Report

Merging #719 (d21d968) into master (cb81237) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #719   +/-   ##
=======================================
  Coverage   99.34%   99.34%           
=======================================
  Files          73       73           
  Lines       11125    11142   +17     
=======================================
+ Hits        11052    11069   +17     
  Misses         73       73           
Flag Coverage Δ
rust 99.79% <100.00%> (+<0.01%) ⬆️
spectests 90.84% <ø> (ø)
unittests 99.32% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
bindings/rust/src/lib.rs 99.79% <100.00%> (+<0.01%) ⬆️

@@ -20,10 +20,21 @@ pub struct Module(*const sys::FizzyModule);

impl Drop for Module {
fn drop(&mut self) {
debug_assert!(!self.0.is_null());
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed these to debug_assert and added it to all relevant places. A failure of this would mean a programming error in our code, and not user code. Hence debug_assert, i.e. it will be caught by our tests assuming we have high enough coverage.

fn clone(&self) -> Self {
debug_assert!(!self.0.is_null());
let ptr = unsafe { sys::fizzy_clone_module(self.0) };
// TODO: this can be zero in case of memory allocation error, should this be gracefully handled?
Copy link
Member Author

Choose a reason for hiding this comment

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

That being said the clone trait does not support optionality.

@axic axic marked this pull request as ready for review February 4, 2021 11:00
@axic axic requested review from gumb0 and chfast February 4, 2021 11:00
@axic axic mentioned this pull request Feb 4, 2021
16 tasks
@axic axic merged commit 5028558 into master Feb 5, 2021
@axic axic deleted the rust-clone branch February 5, 2021 14:00
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.

3 participants