Skip to content

An alternative approach to AnchorFromBlockPosition. #1266

@evanlinjin

Description

@evanlinjin

This was done previously in #1041 but I missed it. Why can't we just have BlockPosition: Into<A> bound instead of adding our own conversion trait?

Originally posted by @LLFourn in #1172 (comment)

@evanlinjin's response:

It's because there are 3 inputs and doing A: From<(&Block, BlockId, usize)> is confusing and we won't know what the usize is for.

An alternative would be to have:

/// Parameters for constructing an [`Anchor`].
pub struct AnchorParams<'b> {
    pub block: &'b Block,
    pub block_id: BlockId,
    pub tx_pos: usize,
}

fn some_method<A: Anchor + From<AnchorParams>>() { todo!() }

What do you think? (AnchorParams will be nicely documented of course!)

Metadata

Metadata

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions