chore: rewrite docstrings with generics
ci/woodpecker/pr/docs Pipeline failed Details
ci/woodpecker/pr/lint Pipeline failed Details
ci/woodpecker/pr/build Pipeline failed Details
ci/woodpecker/pr/docker unknown status Details
ci/woodpecker/pr/man unknown status Details
ci/woodpecker/pr/test Pipeline failed Details

pull/347/head
Jef Roosens 2023-02-08 11:11:28 +01:00
parent 91a976c634
commit b9598ca046
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
5 changed files with 8 additions and 8 deletions

View File

@ -80,7 +80,7 @@ pub fn init(db_path string) !VieterDb {
} }
} }
// row_into<T> converts an sqlite.Row into a given type T by parsing each field // row_into[T] converts an sqlite.Row into a given type T by parsing each field
// from a string according to its type. // from a string according to its type.
pub fn row_into[T](row sqlite.Row) T { pub fn row_into[T](row sqlite.Row) T {
mut i := 0 mut i := 0

View File

@ -2,7 +2,7 @@ module models
import time import time
// from_params<T> creates a new instance of T from the given map by parsing all // from_params[T] creates a new instance of T from the given map by parsing all
// of its fields from the map. // of its fields from the map.
pub fn from_params[T](params map[string]string) ?T { pub fn from_params[T](params map[string]string) ?T {
mut o := T{} mut o := T{}
@ -12,7 +12,7 @@ pub fn from_params[T](params map[string]string) ?T {
return o return o
} }
// patch_from_params<T> updates the given T object with the params defined in // patch_from_params[T] updates the given T object with the params defined in
// the map. // the map.
pub fn patch_from_params[T](mut o T, params map[string]string) ? { pub fn patch_from_params[T](mut o T, params map[string]string) ? {
$for field in T.fields { $for field in T.fields {
@ -36,7 +36,7 @@ pub fn patch_from_params[T](mut o T, params map[string]string) ? {
} }
} }
// params_from<T> converts a given T struct into a map of strings. // params_from[T] converts a given T struct into a map of strings.
pub fn params_from[T](o &T) map[string]string { pub fn params_from[T](o &T) map[string]string {
mut out := map[string]string{} mut out := map[string]string{}

View File

@ -48,7 +48,7 @@ pub fn reader_to_file(mut reader io.BufferedReader, length int, path string) ! {
} }
} }
// match_array_in_array<T> returns how many elements of a2 overlap with a1. For // match_array_in_array[T] returns how many elements of a2 overlap with a1. For
// example, if a1 = "abcd" & a2 = "cd", the result will be 2. If the match is // example, if a1 = "abcd" & a2 = "cd", the result will be 2. If the match is
// not at the end of a1, the result is 0. // not at the end of a1, the result is 0.
pub fn match_array_in_array[T](a1 []T, a2 []T) int { pub fn match_array_in_array[T](a1 []T, a2 []T) int {

View File

@ -15,7 +15,7 @@ pub fn new_response(message string) Response[string] {
} }
} }
// new_data_response<T> constructs a new Response<T> object with the given data // new_data_response[T] constructs a new Response<T> object with the given data
// & an empty message field. // & an empty message field.
pub fn new_data_response[T](data T) Response[T] { pub fn new_data_response[T](data T) Response[T] {
return Response[T]{ return Response[T]{
@ -24,7 +24,7 @@ pub fn new_data_response[T](data T) Response[T] {
} }
} }
// new_full_response<T> constructs a new Response<T> object with the given // new_full_response[T] constructs a new Response<T> object with the given
// message & data. // message & data.
pub fn new_full_response[T](message string, data T) Response[T] { pub fn new_full_response[T](message string, data T) Response[T] {
return Response[T]{ return Response[T]{

View File

@ -157,7 +157,7 @@ pub fn (mut ctx Context) body(status http.Status, content_type string, body stri
return Result{} return Result{}
} }
// json<T> HTTP_OK with json_s as payload with content-type `application/json` // json[T] HTTP_OK with json_s as payload with content-type `application/json`
pub fn (mut ctx Context) json[T](status http.Status, j T) Result { pub fn (mut ctx Context) json[T](status http.Status, j T) Result {
ctx.status = status ctx.status = status
ctx.content_type = 'application/json' ctx.content_type = 'application/json'