Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

fix/get: add missing api to AppendOnlyData trait #121

Closed
wants to merge 6 commits into from

Conversation

oetyng
Copy link
Contributor

@oetyng oetyng commented Oct 21, 2019

Getting Entry by index is missing, but exists for Owner and Permissions.
REFERENCE: #119

Getting Entry by index is missing, but exists for Owner and Permissions.
REFERENCE: maidsafe#119
@oetyng oetyng requested review from mrcnski and Yoga07 October 21, 2019 11:16
@oetyng oetyng requested a review from ustulation as a code owner October 21, 2019 11:16
@oetyng
Copy link
Contributor Author

oetyng commented Oct 21, 2019

Hmm. It is failing Travis due to code that did not change in this PR. Not sure why.

@Yoga07
Copy link
Contributor

Yoga07 commented Oct 21, 2019

Hmm. It is failing Travis due to code that did not change in this PR. Not sure why.

It's from here @oetyng.
https://github.com/maidsafe/safe-nd/pull/121/files#diff-d03d8576cec38966d9ac8eda6c082f23R1432
Running rustfmt would clean it up :)

mrcnski
mrcnski previously approved these changes Oct 21, 2019
There is unnecessary duplication of code in the new `get_entry` test.
@oetyng
Copy link
Contributor Author

oetyng commented Oct 21, 2019

Dismissed by push, sorry @m-cat :)
Now tests are cleaner though.

mrcnski
mrcnski previously approved these changes Oct 21, 2019
Copy link
Contributor

@mrcnski mrcnski left a comment

Choose a reason for hiding this comment

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

Looks great 😄

@oetyng
Copy link
Contributor Author

oetyng commented Oct 21, 2019

Oh not again, I thought I would make it before you reviewed!
I improved it one slight tiny bit more :)

@@ -1398,11 +1398,11 @@ mod tests {
for data in data_vec {
assert_eq!(
data.entry(Index::FromStart(0)),
Some(&Entry::new(b"key0".to_vec(), b"value0".to_vec()))
Some(&entries.clone()[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this clone the entire vec? I think entries[0].clone() is what you want, but I haven't tested it.

Of course, this is just a test so the performance here isn't important.

Copy link
Contributor Author

@oetyng oetyng Oct 21, 2019

Choose a reason for hiding this comment

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

You're right! And actually, no need for clone at all there I realised. I was first thinking that the cloned entries vec was a shallow clone, and that the entries within needed to be cloned. But apparently cloning the vec must have cloned the contents as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

If the entries inside the Vec are a Clone type, then they will be cloned (even if they are a reference), otherwise if they are a reference but not a Clone type the references themselves will be cloned (shallow clone), otherwise you get a compiler error

@mrcnski
Copy link
Contributor

mrcnski commented Oct 21, 2019

Oh not again, I thought I would make it before you reviewed!
I improved it one slight tiny bit more :)

No worries 🙂

Looks good, but I'll wait this time until the CI issues are fixed

@lionel-faber
Copy link
Contributor

These changes look good. CI is failing because of rust-lang/rust-clippy#4326.
@m-cat has a temporary fix in #123 so once that is merged, we can rebase merge this PR.
Thanks @oetyng!

@mrcnski
Copy link
Contributor

mrcnski commented Nov 15, 2019

@oetyng Can you include this change in this PR:

https://github.com/maidsafe/safe-nd/pull/123/files#diff-d03d8576cec38966d9ac8eda6c082f23R60

so we can get this merged quicker without waiting on #123 (not sure when that will be reviewed/approved and its a larger change)

@lionel-faber
Copy link
Contributor

Closing this since this data type is being replaced with Sequence and Map

@oetyng oetyng deleted the master branch February 13, 2020 19:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants