🚀 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:
@ -27,7 +27,7 @@
|
||||
* result = text.concat(" Nyash") // "Hello, World! Nyash"
|
||||
* ```
|
||||
*/
|
||||
use crate::box_trait::NyashBox;
|
||||
use crate::box_trait::{NyashBox, BoxCore, BoxBase};
|
||||
use std::any::Any;
|
||||
use std::fmt::Display;
|
||||
|
||||
@ -35,20 +35,14 @@ use std::fmt::Display;
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct StringBox {
|
||||
pub value: String,
|
||||
id: u64,
|
||||
base: BoxBase,
|
||||
}
|
||||
|
||||
impl StringBox {
|
||||
pub fn new(value: impl Into<String>) -> Self {
|
||||
static mut COUNTER: u64 = 0;
|
||||
let id = unsafe {
|
||||
COUNTER += 1;
|
||||
COUNTER
|
||||
};
|
||||
|
||||
Self {
|
||||
value: value.into(),
|
||||
id,
|
||||
base: BoxBase::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,13 +155,20 @@ impl NyashBox for StringBox {
|
||||
self
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl BoxCore for StringBox {
|
||||
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 StringBox {
|
||||
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