1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

doc: fix function heading (#16307)

This commit is contained in:
kahsa 2022-11-03 13:38:07 +09:00 committed by GitHub
parent dddcf423db
commit 1ecf7c6e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -323,8 +323,8 @@ fn private_function() {
``` ```
Functions are private (not exported) by default. Functions are private (not exported) by default.
To allow other modules to use them, prepend `pub`. The same applies To allow other [modules](#module-imports) to use them, prepend `pub`. The same applies
to constants and types. to [structs](#structs), [constants](#constants) and [types](#type-declarations).
Note: `pub` can only be used from a named module. Note: `pub` can only be used from a named module.
For information about creating a module, see [Modules](#modules). For information about creating a module, see [Modules](#modules).
@ -2886,6 +2886,8 @@ the expression itself, and the expression value.
Every file in the root of a folder is part of the same module. Every file in the root of a folder is part of the same module.
Simple programs don't need to specify module name, in which case it defaults to 'main'. Simple programs don't need to specify module name, in which case it defaults to 'main'.
See [symbol visibility](#symbol-visibility), [Access modifiers](#access-modifiers).
### Create modules ### Create modules
V is a very modular language. Creating reusable modules is encouraged and is V is a very modular language. Creating reusable modules is encouraged and is
@ -2991,25 +2993,25 @@ of an interface.
// interface-example.2 // interface-example.2
module main module main
pub interface Foo { interface Foo {
write(string) string write(string) string
} }
// => the method signature of a type, implementing interface Foo should be: // => the method signature of a type, implementing interface Foo should be:
// `pub fn (s Type) write(a string) string` // `fn (s Type) write(a string) string`
pub interface Bar { interface Bar {
mut: mut:
write(string) string write(string) string
} }
// => the method signature of a type, implementing interface Bar should be: // => the method signature of a type, implementing interface Bar should be:
// `pub fn (mut s Type) write(a string) string` // `fn (mut s Type) write(a string) string`
struct MyStruct {} struct MyStruct {}
// MyStruct implements the interface Foo, but *not* interface Bar // MyStruct implements the interface Foo, but *not* interface Bar
pub fn (s MyStruct) write(a string) string { fn (s MyStruct) write(a string) string {
return a return a
} }