Getting the current user in Drupal 8

https://drupal.org/node/2017231

<?php
use Drupal\Core\Session\AccountInterface;
function mymodule_function() {
  $account = \Drupal::currentUser();
  if ($account->id()) {
    // User is logged in.
  }
}
function mymodule_needs_user(AccountInterface $user) {
}