Skip to content

Commit

Permalink
型エイリアスを導入し、フィールド設定関数のシグネチャを改善
Browse files Browse the repository at this point in the history
- `StringFields`、`IntegerFields`、`FloatFields`の型エイリアスを追加
- 関数の戻り値の型をより明確かつ簡潔に定義
- コードの可読性と型安全性を向上
  • Loading branch information
eda3 committed Mar 3, 2025
1 parent beeafc3 commit f5b74a3
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/commands/update/framedata_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,9 @@ fn format_input_name(input: &str, name: &str) -> String {
}
}

/// `文字列型フィールドをMoveInfoに設定する補助関数`
fn set_string_fields(
move_data: &Data,
empty: &str,
) -> (
// 型エイリアス定義
/// 文字列フィールドのタプル型
type StringFields = (
String,
String,
String,
Expand All @@ -179,7 +177,20 @@ fn set_string_fields(
String,
String,
String,
) {
);
/// 整数フィールドのタプル型
type IntegerFields = (Option<i32>, Option<i32>, Option<i32>, Option<i32>);
/// 浮動小数点フィールドのタプル型
type FloatFields = (
Option<f64>,
Option<f64>,
Option<f64>,
Option<f64>,
Option<f64>,
);

/// `文字列型フィールドをMoveInfoに設定する補助関数`
fn set_string_fields(move_data: &Data, empty: &str) -> StringFields {
(
// 名前
move_data.title.name.as_deref().unwrap_or(empty).to_string(),
Expand Down Expand Up @@ -250,7 +261,7 @@ fn set_string_fields(
}

/// 数値型フィールドをMoveInfoに設定する補助関数(整数型)
fn set_integer_fields(move_data: &Data) -> (Option<i32>, Option<i32>, Option<i32>, Option<i32>) {
fn set_integer_fields(move_data: &Data) -> IntegerFields {
(
// ダメージ
move_data
Expand Down Expand Up @@ -280,15 +291,7 @@ fn set_integer_fields(move_data: &Data) -> (Option<i32>, Option<i32>, Option<i32
}

/// 数値型フィールドをMoveInfoに設定する補助関数(浮動小数点型)
fn set_float_fields(
move_data: &Data,
) -> (
Option<f64>,
Option<f64>,
Option<f64>,
Option<f64>,
Option<f64>,
) {
fn set_float_fields(move_data: &Data) -> FloatFields {
(
// リスクゲイン
move_data
Expand Down

0 comments on commit f5b74a3

Please sign in to comment.