Skip to content

Commit

Permalink
remove the warning code
Browse files Browse the repository at this point in the history
add profile.release to reduce the release size
  • Loading branch information
yaojp committed Jan 17, 2023
1 parent 11ac029 commit fe96fff
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["yao <[email protected]>"]
edition = "2021"
name = "mock-server"
version = "1.0.0"
version = "1.0.1"

[dependencies]
axum = "0.5.13"
Expand All @@ -17,3 +17,7 @@ tower-http = {version = "0.3.4", features = ["fs", "trace", "cors"]}
tracing = "0.1.36"
tracing-subscriber = {version = "0.3.15", features = ["registry", "fmt"]}
uuid = {version = "1.1.2", features = ["v4"]}

[profile.release]
lto = true
opt-level = "z"
6 changes: 1 addition & 5 deletions src/models/data_config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use crate::util;

use super::{Wrapper, WRAP_KEY_ERR, WRAP_KEY_OK};
use axum::{response::IntoResponse, Json};
use serde_json::{json, Value};
use serde_json::Value;
use std::collections::HashMap;

#[derive(Debug, serde::Deserialize, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions src/template/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ pub fn pick(arr: &Vec<Value>) -> &Value {
&arr[index]
}

pub fn shuffle<T>(arr: Vec<T>, min: u32, max: u32) {}

pub fn char(pool: &str) -> char {
let pools = HashMap::from([
("lower", "abcdefghijklmnopqrstuvwxyz"),
Expand All @@ -29,6 +27,7 @@ pub fn char(pool: &str) -> char {
chars[idx] as char
}

#[allow(dead_code)]
pub fn int(min: usize, max: usize) -> usize {
random(min, max)
}
Expand All @@ -38,6 +37,7 @@ pub fn bool() -> bool {
ret == 1
}

#[allow(dead_code)]
pub fn float(min: usize, max: usize, dmin: usize, dmax: usize) -> f64 {
let mut ret = String::new();
let count = random(min, max);
Expand Down
17 changes: 8 additions & 9 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::{
models::{
Wrapper, WRAP_DATA, WRAP_KEY_ERR, WRAP_KEY_OK, WRAP_MSG, WRAP_PAGE, WRAP_PAGE_ITEMS,
WRAP_PAGE_PAGE, WRAP_PAGE_SIZE, WRAP_PAGE_TOTAL,
},
HashMap,
}
};
use axum::{response::IntoResponse, Json};
use serde_json::{json, Value};
Expand All @@ -22,15 +21,15 @@ use std::cmp::Ordering;
// }

/// find json by given keys
pub fn find_by_data_name<'a>(data: &'a Value, data_name: &str) -> Result<&'a Value, String> {
let json = &data[data_name];
// pub fn find_by_data_name<'a>(data: &'a Value, data_name: &str) -> Result<&'a Value, String> {
// let json = &data[data_name];

if !json.is_null() && json.is_array() {
return Ok(&json);
}
// if !json.is_null() && json.is_array() {
// return Ok(&json);
// }

Err("not found by data_name {data_name}".to_string())
}
// Err("not found by data_name {data_name}".to_string())
// }

// pub fn find_by_data_name_mut<'a>(
// data: &'a mut Value,
Expand Down

0 comments on commit fe96fff

Please sign in to comment.