From edd9e3fde9244845de4bbbc999c7214affe23e55 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Tue, 1 Nov 2022 20:58:27 +0100 Subject: [PATCH] refactor: switch to new ! syntax --- client.v | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client.v b/client.v index 4d69edc..eafc8c4 100644 --- a/client.v +++ b/client.v @@ -30,7 +30,7 @@ struct Response { results []Package } -fn (c Client) request(params map[string][]string) ?[]Package { +fn (c Client) request(params map[string][]string) ![]Package { mut param_strings := []string{} for k, v in params { @@ -39,14 +39,14 @@ fn (c Client) request(params map[string][]string) ?[]Package { url := '$c.url?${param_strings.join('&')}' - res := http.get(url)? + res := http.get(url)! if res.status_code < 200 || res.status_code >= 300 { // temporary return error('error') } - data := json.decode(Response, res.body)? + data := json.decode(Response, res.body)! if data.@type == 'error' { return error('Server responded with an error: $data.error') @@ -55,7 +55,7 @@ fn (c Client) request(params map[string][]string) ?[]Package { return data.results } -pub fn (c Client) search_by(arg string, st SearchType) ?[]Package { +pub fn (c Client) search_by(arg string, st SearchType) ![]Package { params := { 'v': ['5'] 'type': ['search'] @@ -67,11 +67,11 @@ pub fn (c Client) search_by(arg string, st SearchType) ?[]Package { } // search performs a search by name_desc. -pub fn (c Client) search(arg string) ?[]Package { +pub fn (c Client) search(arg string) ![]Package { return c.search_by(arg, .name_desc) } -pub fn (c Client) info(pkgs []string) ?[]Package { +pub fn (c Client) info(pkgs []string) ![]Package { params := { 'v': ['5'] 'type': ['info']