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

Feature cleanup #31

Closed
wants to merge 1 commit into from
Closed

Conversation

knickish
Copy link

This branch just does the work related to allowing the feature flags to actually be used. Currently only some combinations will work, this pr makes it so that any combination of the serialization types may be used.

Copy link
Owner

@seladb seladb left a comment

Choose a reason for hiding this comment

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

There are still a lot of changes in this PR. I started reviewing some of the files and added a few comments. In general - I'd like to avoid as much as possible adding #[cfg(...)] everywhere - it makes the code much more complex, harder to read and harder to maintain. Let's think how to simplify it?

@@ -23,7 +23,7 @@ impl<'a> PickleDbListExtender<'a> {
///
/// # Examples
///
/// ```no_run
/// ```ignore
Copy link
Owner

Choose a reason for hiding this comment

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

why change no_run to ignore?

no_run just doesn't run the code, but ignore doesn't even build it 🤔

@@ -6,6 +6,7 @@ pub struct TestResources {
}

impl TestResources {
#[allow(dead_code)]
Copy link
Owner

Choose a reason for hiding this comment

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

Do you know why this is needed? We do use ommon::TestResources::new(...) 🤔

assert!(db.lget::<Vec<i32>>("list1", 0).is_none());

if let SerializationMethod::Yaml = ser_method!(ser_method_int) {
{
Copy link
Owner

Choose a reason for hiding this comment

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

Why add those extra curly brackets?

@@ -239,6 +277,7 @@ fn override_lists(ser_method_int: i32) {
}
}

#[cfg(all(feature = "bincode", feature = "yaml"))]
Copy link
Owner

Choose a reason for hiding this comment

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

why limiting this test to only bincode and yaml?

@@ -1,16 +1,48 @@
#![allow(clippy::float_cmp)]

use pickledb::{PickleDb, PickleDbDumpPolicy, SerializationMethod};
#[cfg(any(
Copy link
Owner

Choose a reason for hiding this comment

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

I must admit I don't really like adding the supported configuration to every test, it significantly bloats the code and will make adding a new configuration require tons of changes. Unless it's absolutely necessary I'd prefer to avoid it

Comment on lines +25 to +34
#[derive(Serialize, Deserialize, Debug)]
struct Coor {
x: i32,
y: i32,
}

#[derive(Serialize, Deserialize, Debug)]
struct MySquare {
x: u32,
}
Copy link
Owner

Choose a reason for hiding this comment

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

Why extract these structs outside of the test case?

@knickish
Copy link
Author

knickish commented Sep 19, 2022

Ok, I couldn't come up with a better way at the time. I need nanoserde for my project so I'll just use my fork for now, and upstream it if I come up with a cleaner way.
E: missed the inline stuff on mobile

@seladb
Copy link
Owner

seladb commented Sep 20, 2022

Ok, I couldn't come up with a better way at the time. I need nanoserde for my project so I'll just use my fork for now, and upstream it if I come up with a cleaner way. E: missed the inline stuff on mobile

ok sure, please feel free to open another PR at a later time. Should we close this one and #30 or do you prefer to keep them open?

@knickish
Copy link
Author

I'll go ahead and close them, and just make a new one if I come up with a cleaner way to support alternative serialization libs. Thanks!

@knickish knickish closed this Sep 21, 2022
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.

None yet

2 participants