coc

Crates.iococ
lib.rscoc
version0.1.1
created_at2025-03-29 07:39:11.29693+00
updated_at2025-03-29 08:11:17.060061+00
descriptionA useful macro collections for struct
homepage
repositoryhttps://github.com/SandmeyerX/coc
max_upload_size
id1610906
size6,608
Sandmeyer (SandmeyerX)

documentation

README

public_fields

Makes both the struct itself and all its fields publicly accessible.

To expose a struct and its fields outside the current module:

  1. Annotate the struct definition with pub
  2. Explicitly mark each field with pub modifier

This allows external code to:

  • Construct instances directly using struct literal syntax
  • Read/modify individual fields without accessor methods

Example

pub struct Foo {
   a: i32,
   b: i32, 
}

// External code can:
let foo = Foo { a: 2, b: 10 };
assert_eq!(foo.a, 2);
assert_eq!(foo.b, 10);

Note

Struct visibility also depends on parent module's visibility1,4. The containing module must be public to allow cross-module access.

For crate-internal visibility, consider pub(crate) instead1,2.

Commit count: 10

cargo fmt