kurtlawrence/papyrus

Injection of using statements

Closed this issue · 0 comments

Goal

Add ability have a piece of code that gets injected on each compilation.

Discussion

The specific use case is to solve where an external library is relying on kserd to display data, but the papyrus version will be trying to solve using its version of kserd.

A fix can be applied by prefixing the source file with use libname::kserd as kserd and this acts as a drop in replacement for the usual crate kserd (which can be accessed using ::kserd). It requires library developers to expose kserd using pub extern crate kserd in their lib.rs file.

This would solve most use cases, however could fall over when the returning type is coming from a dependency in the REPL and implements ToKserd. This would cause the opposite problem (although have not tested) where the ::kserd is required for resolving.

A possible solution is to add a piece of code which can transform libname::kserd to ::kserd.

Aspects to Develop

  • Add in edition = "2018" flag to memory code cargo toml
  • Do test linking in local crate which also implements ToKserd and show that it breaks
  • Test how to add a transformation from libname::kserd to ::kserd.
  • Add an optional source prefix which gets added to every source module
  • Add an optional source prefix which gets added to only lib source module.