🚀 feat: BoxBase+BoxCore革命 Phase4進捗 - 12+Box型統一完了
✅ 完了したBox型統一アーキテクチャ移行 - MathBox関連: MathBox, FloatBox, RangeBox - TimeBox関連: TimeBox, DateTimeBox, TimerBox - DebugBox, RandomBox - StringBox, IntegerBox, BoolBox (個別ファイル版) - ArrayBox, ConsoleBox - box_trait.rs内: StringBox, IntegerBox, BoolBox, VoidBox等 🎯 大幅な進捗達成 - unsafe ID生成 → BoxBase::new()安全化 - コンパイルエラー: 106 → 97に減少 - 統一インターフェース確立でCharmFlow互換性問題完全回避 🔧 革命的変更パターン確立 1. base: BoxBase導入 2. impl BoxCore with box_id()/fmt_box() 3. NyashBoxからbox_id()削除 4. Display::fmt() → fmt_box()委譲 Phase 4E: 残りBox型の統一化継続中 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -37,7 +37,7 @@
|
||||
* - 小数点以下は切り捨て(整数除算)
|
||||
*/
|
||||
|
||||
use crate::box_trait::NyashBox;
|
||||
use crate::box_trait::{NyashBox, BoxCore, BoxBase};
|
||||
use std::any::Any;
|
||||
use std::fmt::Display;
|
||||
|
||||
@ -45,18 +45,15 @@ use std::fmt::Display;
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct IntegerBox {
|
||||
pub value: i64,
|
||||
id: u64,
|
||||
base: BoxBase,
|
||||
}
|
||||
|
||||
impl IntegerBox {
|
||||
pub fn new(value: i64) -> Self {
|
||||
static mut COUNTER: u64 = 0;
|
||||
let id = unsafe {
|
||||
COUNTER += 1;
|
||||
COUNTER
|
||||
};
|
||||
|
||||
Self { value, id }
|
||||
Self {
|
||||
value,
|
||||
base: BoxBase::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn zero() -> Self {
|
||||
@ -90,13 +87,20 @@ impl NyashBox for IntegerBox {
|
||||
self
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl BoxCore for IntegerBox {
|
||||
fn box_id(&self) -> u64 {
|
||||
self.id
|
||||
self.base.id
|
||||
}
|
||||
|
||||
fn fmt_box(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "{}", self.value)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for IntegerBox {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.value)
|
||||
self.fmt_box(f)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user