drop commented code

This commit is contained in:
Sandipsinh Rathod 2024-12-22 13:41:17 -05:00
parent 42cbcf1c7b
commit c5a178da1a

@ -87,86 +87,10 @@ fn fix_field<'a>() -> TryFold<'a, (&'a Config, &'a Interface, &'a Record, &'a Fi
o.records.remove(&rec);
o.records.insert(rec);
Valid::succeed(o)
/* for (arg_name, ty) in records {
let arg_name = if arg_name.is_empty() {
// TODO: maybe we can introduce some transformers
// which uses AI to generate better names
base64::prelude::BASE64_STANDARD.encode(arg_name.as_bytes())
} else {
arg_name.clone()
};
let name = format!("{}-{}-{}", rec.name, field.name, arg_name);
println!("name: {}", name);
let new_field = Field {
name: name.clone(),
field_type: ty.clone(),
};
let mut rec = (*rec).clone();
rec.added_fields.push(new_field);
let mut filtered_records = o.records.into_iter().filter(|r| r.name == rec.name).collect::<Vec<_>>();
filtered_records.push(rec);
o.records = filtered_records;
}
Valid::succeed(o)*/
/* Valid::from_iter(records.iter(), |(_, b)| {
fix_field()
.try_fold(&(*config, *interface, *rec, *field, b), o.clone())
}).and_then(|v| {
o.records = v;
Valid::succeed(o)
}).and_then(|mut o| {
})*/
}
// Ideally this case should never happen,
// but we should always throw an error to avoid infinite recursion
_ => return Valid::fail(anyhow::anyhow!("Unknown type: {:?}", field.field_type)),
}
// Valid::succeed(o)
})
}
/*fn fix_field1(ty: &WitType, mut record: Record, interface: Interface) -> Valid<Record, anyhow::Error, anyhow::Error> {
match ty {
WitType::Option(x) => {
fix_field1(x, record)
}
WitType::Result(x, y) => {
if !x.is_primitive() && !y.is_primitive() {
fix_field1(x, record).and_then(|x| fix_field1(y, x))
} else if !x.is_primitive() {
fix_field1(x, record)
} else {
fix_field1(y, record)
}
}
WitType::List(x) => {
fix_field1(x, record)
}
WitType::Tuple(x) => {
Valid::from_iter(x.iter(), |x| fix_field1(x, record))
.and_then(|v| Valid::succeed(v.into_iter().fold(Record::default(), |mut a, b| {
a.added_fields.extend(b.added_fields);
a
})))
}
WitType::Record(val) => {
let mut new_field = Field::default();
for (k, v) in val {
new_field.field_type = v.clone();
}
record.added_fields.push(new_field);
Valid::succeed(record)
}
// Ideally this case should never happen
// but we should always throw an error to avoid infinite recursion
_ => Valid::fail(anyhow::anyhow!("Unknown type: {:?}", ty)),
}
}
*/