title: Is it recommended to use traits to implement utility functions for structs in external crate?
body: <p>I want to implement a simple utility/helper function in Rust. The function just concatenates the path in a struct (from an external crate) and the argument passed. Is it more idiomatic to implement the helper-function as a normal function or as function of a custom trait?</p>
  
  <p>The implementation of the trait-based approach:</p>
  
  <pre><code>use std::path::{Path, PathBuf};
  
  pub trait RepositoryExt {
      fn get_full_path(&amp;self, path_in_repository: &amp;Path) -&gt; PathBuf;
  }
  
  impl RepositoryExt for othercrate::Repository {
      // othercrate::Repository's workdir() returns its path
      fn get_full_path(&amp;self, path_in_repository: &amp;Path) -&gt; PathBuf {
          self.workdir().join(path_in_repository)
      }
  }
  </code></pre>
  
  <p>With just a function:</p>
  
  <pre><code>pub fn get_repository_full_path(repo: othercrate::Repository,
                                  path_in_repository: &amp;Path) -&gt; PathBuf {
      repo.workdir().join(path_in_repository)
  }
  </code></pre>
  
  <p>The trait-based approach shortens the code when using the helper-function, but I'm worried that it may introduce difficulty to understand where it's defined.</p>
  
  <p>Though both implementations should work, I want to know which is the recommended way in Rust.</p>