Skip to content

Commit 0af10ae

Browse files
authored
Merge pull request #181 from qorix-group/arkjedrz_prefer-core-to-std-base
impl: prefer `core` to `std`
2 parents 8699447 + d49712f commit 0af10ae

File tree

12 files changed

+42
-19
lines changed

12 files changed

+42
-19
lines changed

Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ members = [
66
"tests/rust_test_scenarios",
77
]
88

9+
910
[workspace.package]
1011
version = "0.1.0"
1112
edition = "2021"
@@ -18,3 +19,12 @@ rust_kvs_tool = { path = "src/rust/rust_kvs_tool" }
1819
adler32 = "1.2.0"
1920
tinyjson = "2.5.1"
2021
pico-args = "0.5"
22+
23+
24+
[workspace.lints.clippy]
25+
std_instead_of_core = "warn"
26+
alloc_instead_of_core = "warn"
27+
28+
29+
[workspace.lints.rust]
30+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }

src/rust/rust_kvs/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ name = "rust_kvs"
33
version.workspace = true
44
edition.workspace = true
55

6+
67
[dependencies]
78
adler32.workspace = true
89
tinyjson.workspace = true
910

11+
1012
[dev-dependencies]
1113
tempfile = "3.20"
1214

13-
[lints.rust]
14-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }
15+
16+
[lints]
17+
workspace = true

src/rust/rust_kvs/examples/custom_types.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
/// Example for custom types usage for KVS, with serialization and deserialization.
2-
/// - Implementing serialization/deserialization traits for custom types.
3-
/// - Handling external and nested types.
4-
/// - Usage with KVS.
1+
//! Example for custom types usage for KVS, with serialization and deserialization.
2+
//! - Implementing serialization/deserialization traits for custom types.
3+
//! - Handling external and nested types.
4+
//! - Usage with KVS.
5+
6+
use core::net::IpAddr;
57
use rust_kvs::prelude::*;
6-
use std::net::IpAddr;
78
use tempfile::tempdir;
89

910
/// `Point` is used as an example of nested serializable objects.

src/rust/rust_kvs/src/kvs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use crate::kvs_api::{InstanceId, KvsApi, KvsDefaults, KvsLoad, SnapshotId};
1414
use crate::kvs_backend::{KvsBackend, KvsPathResolver};
1515
use crate::kvs_builder::KvsData;
1616
use crate::kvs_value::{KvsMap, KvsValue};
17+
use core::marker::PhantomData;
1718
use std::fs;
18-
use std::marker::PhantomData;
1919
use std::path::PathBuf;
2020
use std::sync::{Arc, Mutex};
2121

@@ -243,8 +243,8 @@ impl<Backend: KvsBackend, PathResolver: KvsPathResolver> KvsApi
243243
/// * `ErrorCode::KeyNotFound`: Key wasn't found in KVS nor in defaults
244244
fn get_value_as<T>(&self, key: &str) -> Result<T, ErrorCode>
245245
where
246-
for<'a> T: TryFrom<&'a KvsValue> + std::clone::Clone,
247-
for<'a> <T as TryFrom<&'a KvsValue>>::Error: std::fmt::Debug,
246+
for<'a> T: TryFrom<&'a KvsValue> + core::clone::Clone,
247+
for<'a> <T as TryFrom<&'a KvsValue>>::Error: core::fmt::Debug,
248248
{
249249
let data = self.data.lock()?;
250250
if let Some(value) = data.kvs_map.get(key) {

src/rust/rust_kvs/src/kvs_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub trait KvsApi {
8181
fn get_value_as<T>(&self, key: &str) -> Result<T, ErrorCode>
8282
where
8383
for<'a> T: TryFrom<&'a KvsValue> + Clone,
84-
for<'a> <T as TryFrom<&'a KvsValue>>::Error: std::fmt::Debug;
84+
for<'a> <T as TryFrom<&'a KvsValue>>::Error: core::fmt::Debug;
8585
fn get_default_value(&self, key: &str) -> Result<KvsValue, ErrorCode>;
8686
fn is_value_default(&self, key: &str) -> Result<bool, ErrorCode>;
8787
fn set_value<S: Into<String>, J: Into<KvsValue>>(

src/rust/rust_kvs/src/kvs_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::kvs::{GenericKvs, KvsParameters};
1414
use crate::kvs_api::{InstanceId, KvsDefaults, KvsLoad, SnapshotId};
1515
use crate::kvs_backend::{KvsBackend, KvsPathResolver};
1616
use crate::kvs_value::KvsMap;
17-
use std::marker::PhantomData;
17+
use core::marker::PhantomData;
1818
use std::path::PathBuf;
1919
use std::sync::{Arc, LazyLock, Mutex, MutexGuard, PoisonError};
2020

@@ -323,7 +323,7 @@ mod kvs_builder_tests {
323323
use crate::kvs_backend::{KvsBackend, KvsPathResolver};
324324
use crate::kvs_builder::{GenericKvsBuilder, KVS_MAX_INSTANCES, KVS_POOL};
325325
use crate::kvs_value::{KvsMap, KvsValue};
326-
use std::ops::DerefMut;
326+
use core::ops::DerefMut;
327327
use std::path::{Path, PathBuf};
328328
use std::sync::{LazyLock, Mutex, MutexGuard};
329329
use tempfile::tempdir;

src/rust/rust_kvs/src/kvs_mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl KvsApi for MockKvs {
8080
fn get_value_as<T>(&self, key: &str) -> Result<T, ErrorCode>
8181
where
8282
for<'a> T: TryFrom<&'a KvsValue> + Clone,
83-
for<'a> <T as TryFrom<&'a KvsValue>>::Error: std::fmt::Debug,
83+
for<'a> <T as TryFrom<&'a KvsValue>>::Error: core::fmt::Debug,
8484
{
8585
if self.fail {
8686
return Err(ErrorCode::UnmappedError);

src/rust/rust_kvs/src/kvs_value.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
//
1010
// SPDX-License-Identifier: Apache-2.0
1111

12-
// TryFrom<&KvsValue> for all supported types
13-
use std::convert::TryFrom;
12+
use core::convert::TryFrom;
1413

1514
/// Key-value storage map type
1615
pub type KvsMap = std::collections::HashMap<String, KvsValue>;
@@ -87,7 +86,7 @@ impl From<()> for KvsValue {
8786
// Macro to implement TryFrom<&KvsValue> for T for each supported type/variant.
8887
macro_rules! impl_tryfrom_kvs_value_to_t {
8988
($to:ty, $variant:ident) => {
90-
impl std::convert::TryFrom<&KvsValue> for $to {
89+
impl core::convert::TryFrom<&KvsValue> for $to {
9190
type Error = String;
9291
fn try_from(value: &KvsValue) -> Result<Self, Self::Error> {
9392
if let KvsValue::$variant(ref n) = value {

src/rust/rust_kvs/tests/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// This is to ensure file is not improperly detected as empty test file.
55

66
use rust_kvs::kvs_value::KvsValue;
7-
use std::iter::zip;
7+
use core::iter::zip;
88

99
/// Compare `KvsValue` objects.
1010
///

src/rust/rust_kvs_tool/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ edition.workspace = true
88
name = "kvs_tool"
99
path = "src/kvs_tool.rs"
1010

11+
1112
[dependencies]
1213
rust_kvs.workspace = true
1314
tinyjson.workspace = true
1415
pico-args.workspace = true
16+
17+
18+
[lints]
19+
workspace = true

0 commit comments

Comments
 (0)