From 088824efdf8c7cb90a3ac3703d894e89081d1303 Mon Sep 17 00:00:00 2001 From: emma Date: Mon, 20 Mar 2023 16:40:43 -0400 Subject: [PATCH] added other toml value types --- src/main.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5aea5a1..a5d12b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Emma Tebibyte + * Copyright (c) 2022–2023 Emma Tebibyte * SPDX-License-Identifier: AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify it under @@ -67,8 +67,7 @@ fn parse_toml( }; match value { - // TODO: Implement other type parsing - Value::Array(array) => { + Value::Array(array) => { // TODO: Split Array logic into separate function let element: String; match index { Some(i) => { @@ -78,7 +77,7 @@ fn parse_toml( Some(val) => val.to_owned(), None => { return Err(( - format!("{:?}: No value at given key.", index), + format!("{:?}: No value at given key.", i), EX_DATAERR )); }, @@ -95,10 +94,10 @@ fn parse_toml( }; out.push_str(&element); }, - Value::Boolean(_boolean) => {}, - Value::Datetime(_datetime) => {}, - Value::Float(_float) => {}, - Value::Integer(_int) => {}, + Value::Boolean(boolean) => out.push_str(&format!("{:?}", boolean)), + Value::Datetime(datetime) => out.push_str(&format!("{:?}", datetime)), + Value::Float(float) => out.push_str(&format!("{:?}", float)), + Value::Integer(int) => out.push_str(&format!("{:?}", int)), Value::String(string) => out.push_str(string.as_str()), _ => return Err((format!("{:?}: No such key.", item), EX_DATAERR)), };