vlib: remove older deprecated functions (#8864)

pull/8867/head
Stanislav Ershov 2021-02-20 23:42:55 +05:00 committed by GitHub
parent 30ed201600
commit c190b6a131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 88 deletions

View File

@ -1557,12 +1557,6 @@ pub fn (s string) limit(max int) string {
return u.substr(0, max)
}
[deprecated]
pub fn (c byte) is_white() bool {
eprintln('warning: `string.is_white` has been deprecated, use `string.is_space` instead')
return c.is_space()
}
// hash returns an integer hash of the string.
pub fn (s string) hash() int {
// mut h := s.hash_cache

View File

@ -15,8 +15,8 @@ import math.bits
// 2. d cannot be set to zero. The factory function will panic.
// 3. If provided d is negative, it will be made positive. n will change as well.
struct Fraction {
n i64
d i64
n i64
d i64
pub:
is_reduced bool
}
@ -82,12 +82,12 @@ fn general_addition_result(f1 Fraction, f2 Fraction, addition bool) Fraction {
}
// Fraction add using operator overloading
pub fn (f1 Fraction) +(f2 Fraction) Fraction {
pub fn (f1 Fraction) + (f2 Fraction) Fraction {
return general_addition_result(f1.reduce(), f2.reduce(), true)
}
// Fraction subtract using operator overloading
pub fn (f1 Fraction) -(f2 Fraction) Fraction {
pub fn (f1 Fraction) - (f2 Fraction) Fraction {
return general_addition_result(f1.reduce(), f2.reduce(), false)
}
@ -122,12 +122,12 @@ fn general_multiplication_result(f1 Fraction, f2 Fraction, multiplication bool)
}
// Fraction multiply using operator overloading
pub fn (f1 Fraction) *(f2 Fraction) Fraction {
pub fn (f1 Fraction) * (f2 Fraction) Fraction {
return general_multiplication_result(f1.reduce(), f2.reduce(), true)
}
// Fraction divide using operator overloading
pub fn (f1 Fraction) /(f2 Fraction) Fraction {
pub fn (f1 Fraction) / (f2 Fraction) Fraction {
if f2.n == 0 {
panic('Cannot divide by zero')
}
@ -139,30 +139,6 @@ pub fn (f1 Fraction) /(f2 Fraction) Fraction {
return general_multiplication_result(f1.reduce(), f2.reduce(), false)
}
// Fraction add method. Deprecated. Use the operator instead.
[deprecated]
pub fn (f1 Fraction) add(f2 Fraction) Fraction {
return f1 + f2
}
// Fraction subtract method. Deprecated. Use the operator instead.
[deprecated]
pub fn (f1 Fraction) subtract(f2 Fraction) Fraction {
return f1 - f2
}
// Fraction multiply method. Deprecated. Use the operator instead.
[deprecated]
pub fn (f1 Fraction) multiply(f2 Fraction) Fraction {
return f1 * f2
}
// Fraction divide method. Deprecated. Use the operator instead.
[deprecated]
pub fn (f1 Fraction) divide(f2 Fraction) Fraction {
return f1 / f2
}
// Fraction negate method
pub fn (f Fraction) negate() Fraction {
return Fraction{

View File

@ -13,12 +13,6 @@ struct FileInfo {
size int
}
[deprecated]
pub fn (f File) is_opened() bool {
eprintln('warning: `File.is_opened()` has been deprecated, use `File.is_opened` instead')
return f.is_opened
}
// **************************** Write ops ***************************
// write implements the Writer interface
pub fn (mut f File) write(buf []byte) ?int {
@ -178,22 +172,6 @@ pub fn open_stdin() File {
}
}
// File.get_line - get a single line from the file. NB: the ending newline is *included*.
[deprecated]
pub fn (mut f File) get_line() ?string {
eprintln('File.get_line() is deprecated... Use a BufferedReader instead')
if !f.is_opened {
return error('file is closed')
}
return error('use io.new_buffered_reader')
/*
mut reader := io.new_buffered_reader({
reader: io.make_reader(f)
})
return reader.read_line()
*/
}
pub fn (mut f File) write_str(s string) ? {
if !f.is_opened {
return error('file is closed')

View File

@ -23,12 +23,6 @@ const (
r_ok = 4
)
[deprecated]
pub fn cp_r(osource_path string, odest_path string, overwrite bool) ? {
eprintln('warning: `os.cp_r` has been deprecated, use `os.cp_all` instead')
return cp_all(osource_path, odest_path, overwrite)
}
// cp_all will recursively copy `src` to `dst`,
// optionally overwriting files or dirs in `dst`.
pub fn cp_all(src string, dst string, overwrite bool) ? {
@ -137,18 +131,6 @@ pub fn sigint_to_signal_name(si int) string {
return 'unknown'
}
[deprecated]
pub fn file_exists(_path string) bool {
eprintln('warning: `os.file_exists` has been deprecated, use `os.exists` instead')
return exists(_path)
}
[deprecated]
pub fn rmdir_recursive(path string) {
eprintln('warning: `os.rmdir_recursive` has been deprecated, use `os.rmdir_all` instead')
rmdir_all(path) or { panic(err) }
}
// rmdir_all recursively removes the specified directory.
pub fn rmdir_all(path string) ? {
mut ret_err := ''
@ -403,12 +385,6 @@ pub fn exists_in_system_path(prog string) bool {
return true
}
[deprecated]
pub fn dir_exists(path string) bool {
eprintln('warning: `os.dir_exists` has been deprecated, use `os.is_dir` instead')
return is_dir(path)
}
// is_file returns a `bool` indicating whether the given `path` is a file.
pub fn is_file(path string) bool {
return exists(path) && !is_dir(path)
@ -490,12 +466,6 @@ pub fn log(s string) {
//}
}
[deprecated]
pub fn flush_stdout() {
eprintln('warning: `os.flush_stdout` has been deprecated, use `os.flush` instead')
flush()
}
// mkdir_all will create a valid full path of all directories given in `path`.
pub fn mkdir_all(path string) ? {
mut p := if path.starts_with(path_separator) { path_separator } else { '' }