senooken JP Social
  • FAQ
  • Login
senooken JP Socialはsenookenの専用分散SNSです。
  • Public

    • Public
    • Network
    • Groups
    • Popular
    • People

Conversation

Notices

  1. Masaki Hara (qnighy@qnmd.info)'s status on Monday, 22-Oct-2018 10:04:15 JST Masaki Hara Masaki Hara

    https://users.rust-lang.org/t/suggestion-a-take-n-like-iterator-method-that-does-not-take-ownership/21479
    イテレータを最初のn個とそれ以降に分割するには?→as_refとtakeを組み合わせる

    In conversation Monday, 22-Oct-2018 10:04:15 JST from qnmd.info permalink

    Attachments

    1. Domain not in remote thumbnail source whitelist: www.rust-lang.org
      Suggestion: a `.take(n)`-like Iterator method that does not take ownership
      from The Rust Programming Language Forum
      Ever wanted to write this kind of code ? fn main () { let mut iterator = (0 .. 10).into_iter(); for x in iterator.take(3) { println!("{} is in the podium!", x); }; for x in iterator { println!("{} is not, but maybe next time?", x); }; } playground Obviously it cannot work since .take(n) takes (duh) ownership of iterator. This can however be fixed by (mutably) borrowing iterator for the time of that first iteration: fn main () { let mut iterator = (0 ...

    Feeds

    • Activity Streams
    • RSS 2.0
    • Atom
    • Help
    • About
    • FAQ
    • TOS
    • Privacy
    • Source
    • Version
    • Contact

    senooken JP Social is a social network, courtesy of senooken. It runs on GNU social, version 2.0.2-beta0, available under the GNU Affero General Public License.

    Creative Commons Attribution 3.0 All senooken JP Social content and data are available under the Creative Commons Attribution 3.0 license.