What grammar is this?

pub trait LocalFilenameFn {
  type Error;
  fn call(
    &self,
    path_data: &PathData,
    asset_info: Option<&AssetInfo>,
  ) -> Result<String, Self::Error>;
}

/// The default filename fn trait.
pub trait FilenameFn: LocalFilenameFn<Error = rspack_error::Error> + Debug + Send + Sync {}

impl LocalFilenameFn for Arc<dyn FilenameFn> {
  type Error = rspack_error::Error;
  fn call(
    &self,
    path_data: &PathData,
    asset_info: Option<&AssetInfo>,
  ) -> Result<String, Self::Error> {
    self.deref().call(path_data, asset_info)
  }
}

<Error = rspack_error::Error> What grammar is this? I couldn't find it in the document.

2 Likes

That's an associated type equality bound, which I guess is not in the reference.

It means that the implementor of FilenameFn must implement LocalFilenameFn, and in the implementation, define the associated type Error as rspack_error::Error.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.