We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Similar to #16, but this time self_cell doesn't allow a custom Ok function:
Ok
use self_cell::self_cell; // Remove this, and it compiles pub fn Ok<T>(t: T) -> Result<T, ()> { Result::Ok(t) } #[derive(Debug, Eq, PartialEq)] struct Ast<'a>(pub Vec<&'a str>); self_cell!( struct AstCell { owner: String, #[covariant] dependent: Ast, } impl {Debug, Eq, PartialEq} ); fn build_ast_cell(code: &str) -> AstCell { // Create owning String on stack. let pre_processed_code = code.trim().to_string(); // Move String into AstCell, then build Ast inplace. AstCell::new(pre_processed_code, |code| { Ast(code.split(' ').filter(|word| word.len() > 1).collect()) }) } fn main() { let ast_cell = build_ast_cell("fox = cat + dog"); println!("ast_cell -> {:?}", &ast_cell); println!("ast_cell.borrow_owner() -> {:?}", ast_cell.borrow_owner()); println!( "ast_cell.borrow_dependent().0[1] -> {:?}", ast_cell.borrow_dependent().0[1] ); }
Compile error:
error[E0308]: mismatched types --> svc-gateway-host-run/src/e.rs:11:1 | 11 | / self_cell!( 12 | | struct AstCell { 13 | | owner: String, 14 | | ... | 19 | | impl {Debug, Eq, PartialEq} 20 | | ); | | ^ | | | | | expected `Result<AstCell, Err>`, found `Result<AstCell, ()>` | |_expected this type parameter | expected `Result<AstCell, Err>` because of return type | = note: expected enum `Result<_, Err>` found enum `Result<_, ()>` = note: this error originates in the macro `self_cell` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> svc-gateway-host-run/src/e.rs:11:1 | 11 | / self_cell!( 12 | | struct AstCell { 13 | | owner: String, 14 | | ... | 19 | | impl {Debug, Eq, PartialEq} 20 | | ); | | ^ | | | | |_expected `Result<AstCell, (..., ...)>`, found `Result<AstCell, ()>` | expected `Result<AstCell, (String, Err)>` because of return type | = note: expected enum `Result<_, (String, Err)>` found enum `Result<_, ()>` = note: this error originates in the macro `self_cell` (in Nightly builds, run with -Z macro-backtrace for more info)
Context: was trying out anyhow's Ok helper
The text was updated successfully, but these errors were encountered:
Thanks for bringing up the issue. I've created a PR with a fix for the issue. Please let me know if that addresses your issues.
Sorry, something went wrong.
I just released https://github.com/Voultapher/self_cell/releases/tag/v1.0.3 which contains the fix.
Thanks!
Successfully merging a pull request may close this issue.
Similar to #16, but this time self_cell doesn't allow a custom
Ok
function:Compile error:
Context: was trying out anyhow's
Ok
helperThe text was updated successfully, but these errors were encountered: