close
Skip to content

Make MetaMember::name 'a instead of 'static#295

Open
dubrowgn wants to merge 1 commit into
Indra-db:mainfrom
dubrowgn:pr/non-static-meta
Open

Make MetaMember::name 'a instead of 'static#295
dubrowgn wants to merge 1 commit into
Indra-db:mainfrom
dubrowgn:pr/non-static-meta

Conversation

@dubrowgn
Copy link
Copy Markdown

UntypedComponent::member() and friends take a MetaMember with a 'static name string. This string is then immediately copied into a c-string before use, so the 'static lifetime is not necessary. The name only needs to live for the duration of the function call.

Using 'static is fine for many cases, but makes generating arbitrary component members at runtime problematic. Given the nature of the API, this usecase is highly likely.

Instead of using 'static name, use 'a instead, such that generating dynamic component members at runtime using dynamic string names is easily possible.

UntypedComponent::member() and friends take a MetaMember with a 'static
name string. This string is then immediately copied into a c-string
before use, so the 'static lifetime is not necessary. The name only
needs to lives for the duration of the function call.

Using 'static is fine for many cases, but makes makes generating
arbitrary component members at runtime problematic. Given the nature of
the API, this usecase is highly likely.

Instead of using 'static name, use 'a instead, such that generating
dynamic component members at runtime using dynamic string names is
easily possible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant