Error[e0412]:在此范围中找不到类型`programResult'

问题描述 投票:0回答:2
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 {}
i我有上面的源锈蚀代码,下面的错误。

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

有任何建议吗?
使用锚点
    

这解决了这个问题。您必须明确导入IT

rust blockchain smartcontracts solana anchor-solana
2个回答
11
投票

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

7
投票

trone结果

为程序恢复原因, ProgramResult是已在较旧的锚点项目中使用的类型别名,在较新的锚定版本中,IT支持错误处理的结果,结果约定也将删除从您的项目中导入的不必要的库。
	
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.