rust 错误[E0412]:在此范围内找不到'ProgramResult'类型

rryofs0p  于 2022-11-30  发布在  其他
关注(0)|答案(2)|浏览(272)
use anchor_lang::prelude::*;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

#[program]
pub mod myepicproject {
  use super::*;
  pub fn start_stuff_off(ctx: Context<StartStuffOff>) -> ProgramResult {
    Ok(())
  }
}

#[derive(Accounts)]
pub struct StartStuffOff {}

我有上面的源代码和下面的错误。

error[E0412]: cannot find type `ProgramResult` in this scope
 --> programs/myepicproject/src/lib.rs:8:58
  |
8 |   pub fn start_stuff_off(ctx: Context<StartStuffOff>) -> ProgramResult {
  |                                                          ^^^^^^^^^^^^^ not found in this scope

For more information about this error, try `rustc --explain E0412`.
error: could not compile `myepicproject` due to previous error

有什么建议吗?
使用锚

bfrts1fy

bfrts1fy1#

这解决了这个问题.你必须明确地导入它

use anchor_lang::solana_program::entrypoint::ProgramResult;
o3imoua4

o3imoua42#

这样试试看:

pub fn start_stuff_off(ctx: Context<StartStuffOff>) -> Result<()> {

相关问题