title: Where do I find the complexity of an operation?
body: <p>In <a href="https://stackoverflow.com/a/46290728/1994377">this answer</a> it is mentioned that for a string doing 
  <code>s.chars().count()</code> to get the number of characters is an O(n) operation.
  For simple ASCII strings getting the number of bytes using <code>s.len()</code> works as well. When using a check to make sure that all those bytes are actually ASCII this is probably safe.</p>
  
  <p>I want to know what the complexity of that operation is. It might still have to find the end of the string like in C and be O(n).</p>
  
  <p>I tried to look it up and found the <a href="https://doc.rust-lang.org/std/string/struct.String.html#method.len" rel="nofollow noreferrer">documentation of the <code>std::string::String</code></a>,
   which applies for appropriate <code>s</code>. However it doesn't state its complexity. Looking at the source it just does this <code>self.vec.len()</code>. So we go to look at the <a href="https://doc.rust-lang.org/std/vec/struct.Vec.html#method.len" rel="nofollow noreferrer">vector docs</a> and find that this simply returns a stored length <code>self.len</code> meaning that this is indeed an O(1) operation.</p>
  
  <p>That was a lot of work though. Now what about the case that <code>s</code> is a <a href="https://doc.rust-lang.org/std/str/" rel="nofollow noreferrer">std::str</a>? I tried to do the same but got stuck in <a href="http://www.cs.brandeis.edu/~cs146a/rust/doc-02-21-2015/nightly/src/core/str/mod.rs.html#1327-1367" rel="nofollow noreferrer">this mess</a>.</p>
  
  <p>Is there a more easily accessible ressource for operation complexities in Rust?</p>
  
  <p>Something like this <a href="https://wiki.python.org/moin/TimeComplexity" rel="nofollow noreferrer">list for Python</a> would be great.</p>