liveBook · Manning

Public visibility

Also called pub, public access, public keyword

Public visibility is an access-control status that permits a declaration or resource to be accessed from outside its defining scope, subject to applicable visibility rules.

How 8 Manning books explain it

Refactoring to Rust

A visibility modifier is Rust syntax that controls which modules or crates can access an item.

How it is used
Uses visibility to shape module and crate interfaces while keeping shared implementation helpers internal.
How deep it goes
Works through default privacy, crate-restricted visibility, upward module visibility, public signatures, and C-linkable declarations.
Examples
Uses a greeting program, a crate-internal helper, a calculator API with a public error enum, and a C-callable function.
What you can do after
Diagnose privacy errors and apply `pub` or `pub(crate)` to expose intended interfaces.

Read how Refactoring to Rust explains public visibility →

Modern C, Third Edition

Visibility is the property determining whether an identifier can be referenced from a particular part of a program.

How it is used
Uses visibility to determine where C identifiers can be referenced.
How deep it goes
Explains scope boundaries and shadowing, including cases where an object remains accessible despite its identifier being hidden.
Examples
Uses nested local variables, an extern declaration, and nested struct declarations to illustrate visibility.
What you can do after
Diagnose visibility and shadowing in C declarations while distinguishing identifier visibility from object accessibility.

Read how Modern C, Third Edition explains public visibility →

Modern C

Visibility is the property determining where a C identifier can be referred to by name.

How it is used
Explains where C identifiers may be named and how nested declarations alter name lookup.
How deep it goes
Distinguishes scope, shadowing, object accessibility, definitions, and extern declarations through worked examples.
Examples
Uses nested local variables, a pointer, and an extern declaration to demonstrate shadowing and object identity.
What you can do after
Evaluate which declaration a name denotes at each point in a C program and distinguish names from objects.

Read how Modern C explains public visibility →

Kotlin in Action, 2E

Visibility is the access-control property that determines which code can refer to a declaration.

How it is used
Controls access to declarations so implementation details can change without breaking dependent code.
How deep it goes
Defines four modifiers, compares member and top-level rules, and demonstrates property accessors; it defers broader property features.
Examples
Uses a converted Person class, a visibility-modifier table, and a LengthCounter with a private setter.
What you can do after
Apply it in Kotlin to expose APIs deliberately and restrict mutation or implementation details with suitable modifiers.

Read how Kotlin in Action, 2E explains public visibility →

Code Like a Pro in Rust

Visibility is a Rust access-control property that determines which modules and crates can access a declaration or struct field.

How it is used
Uses visibility to control access to declarations and struct fields while organizing crate namespaces.
How deep it goes
Defines default and restricted visibility and illustrates enclosing-module and field-level effects.
Examples
Illustrates public functions in private and public modules and a struct with fields of differing visibility.
What you can do after
Configure Rust visibility for modules, declarations, and struct fields.

Read how Code Like a Pro in Rust explains public visibility →

Idiomatic Rust

Visibility is the language-defined accessibility of a program item from a given scope or module.

How it is used
Exposes selected Rust items to external callers while shaping a library's public API.
How deep it goes
Defines `pub` for fields and items, contrasts direct access with methods, and traces compiler errors for private library interfaces.
Examples
Uses pizza toppings, a bicycle builder API, and a linked-list library tested from outside its crate.
What you can do after
Configure a library API by exposing required types and methods while keeping fields private where access needs control.

Read how Idiomatic Rust explains public visibility →

Learn Rust in a Month of Lunches

Visibility is the Rust access-control property that determines whether an item or field can be referenced from a given module or crate.

How it is used
Controls access across modules and crates while supporting encapsulation of implementation details.
How deep it goes
Explains defaults, compiler feedback, and item-specific rules, but stops short of advanced visibility forms.
Examples
Uses a printing module, an E0603 diagnostic, and a Billy struct with selective field visibility.
What you can do after
Apply Rust pub declarations to expose functions, types, fields, methods, variants, and modules selectively.

Read how Learn Rust in a Month of Lunches explains public visibility →

Learn Go with Pocket-Sized Projects

Visibility is the rule determining whether a Go identifier can be referenced from outside its package, based on its initial capitalization.

How it is used
Controls cross-package access and determines which struct fields Go templates can print.
How deep it goes
Defines capitalization and demonstrates practical access failures, without detailing broader scope rules.
Examples
Uses fmt.Println in a runnable program and Name or WeeklyFrequency in an HTML template.
What you can do after
Apply it by capitalizing identifiers that other packages or templates must access.

Read how Learn Go with Pocket-Sized Projects explains public visibility →

Also covered in

What to know first

Related concepts

Questions about public visibility

What is public visibility?

Public visibility is an access-control status that permits a declaration or resource to be accessed from outside its defining scope, subject to applicable visibility rules.

Which Manning books explain public visibility?

Refactoring to Rust, Modern C, Third Edition, Modern C, Kotlin in Action, 2E, Code Like a Pro in Rust, Idiomatic Rust, Learn Rust in a Month of Lunches and Learn Go with Pocket-Sized Projects.

What should I know before learning public visibility?

Manning books that teach public visibility usually introduce crate, encapsulation, function and method first.

What is the difference between public visibility and storage duration?

Public visibility is an access-control status that permits a declaration or resource to be accessed from outside its defining scope, subject to applicable visibility rules. Storage duration is the C property that determines how long an object exists during program execution and how its storage is managed.

What kinds of public visibility are there?

Kinds of public visibility include internal modifier.

What is public visibility also called?

Public visibility is also called pub, public access or public keyword.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.