Add docs to declare_id macro (#10671)

This commit is contained in:
Tyera Eulberg 2020-06-17 19:57:23 -06:00 committed by GitHub
parent c151e783ca
commit f37d2d5a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -41,12 +41,15 @@ impl ToTokens for Id {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
let id = &self.0;
tokens.extend(quote! {
/// The static program ID
pub static ID: ::solana_sdk::pubkey::Pubkey = #id;
/// Confirms that a given pubkey is equivalent to the program ID
pub fn check_id(id: &::solana_sdk::pubkey::Pubkey) -> bool {
id == &ID
}
/// Returns the program ID
pub fn id() -> ::solana_sdk::pubkey::Pubkey {
ID
}