3 个不稳定版本

0.2.0 2024年2月22日
0.1.1 2024年2月20日
0.1.0 2024年2月20日

#634 in 数据结构

Download history

94 每月下载量

MIT 许可证

28KB
426

billios - 土壤库

GitHub Actions Workflow Status Crates.io Version docs.rs

这个包是土壤相关数据结构和公式的集合。

安装

标准功能,无需额外依赖

[dependencies]
billios = "0.2.0"

或者,您可以使用 cargo add 命令进行安装

cargo add billios

代码示例

示例 - 使用沙子

使用此公式只需要几行代码。

只需用期望的值调用 new() 方法,然后调用 calculate() 来检索结果。

使用常量 sand_in_cone

use billios::field_test::*;

// This constructor  takes 3 arguments:
//
// cone_pre_test, cone_post_test, sand_in_cone
//
// The first two are straight forward; two float values.
// For the third we use the `None` option. The reason for this
// is becouse the `sand_in_cone` argument is a constant (mostly).
// In general this value does not change often, so we don't have to worry
// about setting it. Instead we just use `None`. If for some reason you
// needed to change the value, you simple pass in a `Some(<f64>).
let sand_used = SandUsed::new(14.65, 8.75, None);

// In order to get the calculated value we call the `calculate()` method:
let result = sand_used.calculate();

assert_eq!(2.31, result);

使用自定义 sand_in_cone

use billios::field_test::SandUsed;

let sand_used = SandUsed::new(14.65, 8.75, Some(3.59));
let result = sand_used.calculate();

assert_eq!(2.31, result);

示例 - 压实

使用此公式可能比上一个示例复杂一点。然而,它仍然相当简单。

使用现有的 dry_densitymoisture_content

use billios::field_test::*;

let wet_density = WetDensityChoice::Value(177.1429);
let moisture_content = MoistureContentChoice::Value(0.1428571);
let dry_density = DryDensity::new(wet_density, moisture_content);

let result = dry_density.calculate();

assert_eq!(155., result);

使用 dry_densitymoisture_content 构造函数

没有必要计算每个值。

use billios::field_test::*;

let wd = WetDensity::new(4.65, 2.31, None);
let wet_density = WetDensityChoice::constructor(wd);
let mc = MoistureContent::new(1600., 1575., 1400.);
let moisture_content = MoistureContentChoice::constructor(mc);

let dry_density = DryDensity::new(wet_density, moisture_content);
let result = dry_density.calculate();

assert_eq!(155., result);

待办事项

  • 实现 GitHub Action 工作流程
  • 创建第一个部署到 crates.io
  • 改进 README.md
    • 添加构建/crates.io/docs 徽章
  • 完成文档
    • 至少需要为 crates.io 创建基本文档
    • lib.rs 需要关注
  • 为计算结构添加 Setter() 方法
  • 可能将选择枚举(例如 SandUsedChoices)更改为 SandUsedOption
  • 重构公共 API。特别是如何访问像 domain::types 这样的东西
  • 更多计算?
  • 重命名 utilities.rs
  • calculations.rs 重命名为 field_test.rs

无运行时依赖