more beatify

This commit is contained in:
vms 2020-08-26 19:16:00 +03:00
parent 8f1df6d539
commit 78ef68b5eb
2 changed files with 19 additions and 14 deletions

View File

@ -93,11 +93,10 @@ impl ToString for &RecordType {
.fold(String::new(), |mut accumulator, field_type| {
accumulator.push(' ');
accumulator.push_str(&format!(
"{}: {}\n",
"{}: {},\n",
field_type.name,
(&field_type.ty).to_string()
));
accumulator.push(',');
accumulator
}),
)
@ -173,17 +172,23 @@ fn encode_function_arguments(arguments: &[FunctionArg]) -> String {
} else {
format!(
"\n (param{})",
arguments.iter().fold(
String::new(),
|mut accumulator, FunctionArg { name, ty }| {
accumulator.push(' ');
accumulator.push_str(name);
accumulator.push_str(": ");
accumulator.push_str(&ty.to_string());
accumulator.push(',');
accumulator
}
)
arguments
.iter()
.fold(
(String::new(), true),
|(mut accumulator, is_first), FunctionArg { name, ty }| {
if !is_first {
accumulator.push(',');
}
accumulator.push(' ');
accumulator.push_str(name);
accumulator.push_str(": ");
accumulator.push_str(&ty.to_string());
(accumulator, false)
}
)
.0
)
}
}

View File

@ -1,9 +1,9 @@
#![allow(missing_docs)]
use crate::ast::FunctionArg;
use crate::types::RecordType;
use crate::{types::InterfaceType, values::InterfaceValue};
use std::{cell::Cell, ops::Deref};
use crate::ast::FunctionArg;
pub trait TypedIndex: Copy + Clone {
fn new(index: usize) -> Self;