string: make left/right private

pull/2940/head
Alexander Medvednikov 2019-11-30 12:00:05 +03:00
parent b92a3544f5
commit b38283dcf1
5 changed files with 10 additions and 10 deletions

View File

@ -384,14 +384,14 @@ pub fn (s string) split_into_lines() []string {
}
// 'hello'.left(2) => 'he'
pub fn (s string) left(n int) string {
fn (s string) left(n int) string {
if n >= s.len {
return s
}
return s.substr(0, n)
}
// 'hello'.right(2) => 'llo'
pub fn (s string) right(n int) string {
fn (s string) right(n int) string {
if n >= s.len {
return ''
}

View File

@ -214,7 +214,7 @@ fn (p mut Parser) fn_decl() {
is_public: is_pub || p.is_vh // functions defined in .vh are always public
is_unsafe: p.attr == 'unsafe_fn'
is_deprecated: p.attr == 'deprecated'
comptime_define: if p.attr.starts_with('if ') { p.attr.right(3) } else { '' }
comptime_define: if p.attr.starts_with('if ') { p.attr[3..] } else { '' }
}
is_live := p.attr == 'live' && !p.pref.is_so && p.pref.is_live
if p.attr == 'live' && p.first_pass() && !p.pref.is_live && !p.pref.is_so {

View File

@ -2093,7 +2093,7 @@ fn (p mut Parser) index_expr(typ_ string, fn_ph int) string {
// }
if is_indexer {
l := p.cgen.cur_line.trim_space()
index_val := l.right(l.last_index(' ')).trim_space()
index_val := l[l.last_index(' ')..].trim_space()
p.cgen.resetln(l[..fn_ph])
p.table.varg_access << VargAccess{
fn_name: p.cur_fn.name,

View File

@ -527,7 +527,7 @@ pub fn (t Time) get_fmt_date_str(fmt_dlmtr FormatDelimiter, fmt_date FormatDate)
}
month := '${t.smonth()}'
year := t.year.str().right(2)
year := t.year.str()[2..]
return match fmt_date {
.ddmmyy { '${t.day:02d}|${t.month:02d}|$year' }