text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/hyper/src/ffi/error.rs
use
libc
:
:
size_t
;
pub
struct
hyper_error
(
crate
:
:
Error
)
;
#
[
repr
(
C
)
]
pub
enum
hyper_code
{
HYPERE_OK
HYPERE_ERROR
HYPERE_INVALID_ARG
HYPERE_UNEXPECTED_EOF
HYPERE_ABORTED_BY_CALLBACK
#
[... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/hyper/src/ffi/error.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
/
/
/
Print
the
details
of
this
error
to
a
buffer
.
/
/
/
/
/
/
The
dst_len
value
must
be
the
maximum
length
that
the
buffer
can
/
/
/
store
.
/
/
/
/
/
/
The
return
value
is
number
of
bytes
that
were
written
to
dst
.
fn
hyper_error_print
(
err
:
*
const
hyper_error
dst
:
*
mut
u8
dst_len
:
size_t
)
-
>... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/hyper/src/ffi/error.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: winksaville/fuchsia path: /src/connectivity/wlan/lib/mlme/rust/src/client/state.rs
cess);
Ok(())
}
Err(e) => {
error!("authentication with BSS failed: {}", e);
sta.send_authenticate_conf(fidl_mlme::AuthenticateResultCodes::R... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/src/connectivity/wlan/lib/mlme/rust/src/client/state.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: winksaville/fuchsia path: /src/connectivity/wlan/lib/mlme/rust/src/client/state.rs
ind(reason_code);
}
}
statemachine!(
/// Client state machine.
/// Note: Only authentication is supported right now.
pub enum States,
// Regular successful flow:
() => Joined,
Joined =... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/src/connectivity/wlan/lib/mlme/rust/src/client/state.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Verify no MLME message was sent yet.
device.next_mlme_msg::<fidl_mlme::AuthenticateConfirm>().expect_err("unexpected message");
}
#[test]
fn join_state_authenticate_tx_failure() {
let mut device = FakeDevice::new();
let mut scheduler = FakeScheduler::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/src/connectivity/wlan/lib/mlme/rust/src/client/state.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uber/piranha path: /src/tests/test_piranha_scm.rs
/*
Copyright (c) 2023 Uber Technologies, Inc.
<p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License at
<p>http://www.apache.org... | code_fim | hard | {
"lang": "rust",
"repo": "uber/piranha",
"path": "/src/tests/test_piranha_scm.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>create_rewrite_tests! {
TS_SCHEME,
test_simple_rename: "simple_rename", 1;
}
#[test]
fn test_simple_rename_code_snippet() {
initialize();
let path_to_scenario = PathBuf::from("test-resources")
.join(TS_SCHEME)
.join("simple_rename");
let code_snippet = "(method_declaration name: (_) @n... | code_fim | hard | {
"lang": "rust",
"repo": "uber/piranha",
"path": "/src/tests/test_piranha_scm.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HPRIOR/LearnRust path: /src/generics.rs
// non generic function
fn largest_i32(list: &[i32]) -> i32 {
let mut largest = list[0];
for &item in list {
if item > largest {
largest = item;
}
}
largest
}
// generic version
fn largest<T:PartialOrd + Copy>... | code_fim | hard | {
"lang": "rust",
"repo": "HPRIOR/LearnRust",
"path": "/src/generics.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> PointTwoDataTypes {
x: self.x,
y: other.y,
}
}
}
// generic enums
enum Option<T> {
Some(T),
None,
}
// with two types
enum Result<T, E> {
Ok(T),
Err(E),
}<|fim_prefix|>// repo: HPRIOR/LearnRust path: /src/generics.rs
// non generic function
fn... | code_fim | hard | {
"lang": "rust",
"repo": "HPRIOR/LearnRust",
"path": "/src/generics.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jkillelea/cpuviz path: /build.rs
#![allow(warnings)]
extern crate bindgen;
use std::env;
use std::path::PathBuf;
fn main() {
// jacob@murderbot:~$ pkg-config --libs libgtop-2.0
// -lgtop-2.0 -lglib-2.0
println!("cargo:rustc-link-lib=gtop-2.0");
println!("cargo:rustc-link-lib=glib-2.0");... | code_fim | medium | {
"lang": "rust",
"repo": "Jkillelea/cpuviz",
"path": "/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // // jacob@murderbot:~$ pkg-config --cflags libgtop-2.0
// // -I/usr/include/libgtop-2.0 -I/usr/include/glib-2.0
// // -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
let bindings = bindgen::Builder::default()
.trust_clang_mangling(false) // mangling breaks linking
.clang_arg("-I/usr... | code_fim | medium | {
"lang": "rust",
"repo": "Jkillelea/cpuviz",
"path": "/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Taneb/AoC path: /aoc3/src/main.rs
#[macro_use]
extern crate nom;
use nom::{IResult, digit};
use std::io::{stdin, BufRead, BufReader};
use std::mem::swap;
use std::str;
use std::str::FromStr;
named!(numberp<usize>, map_res!(
map_res!(
ws!(digit),
str::from_utf8
),
Fr... | code_fim | hard | {
"lang": "rust",
"repo": "Taneb/AoC",
"path": "/aoc3/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> swap(&mut (tup.1).0, &mut (tup.0).1);
swap(&mut (tup.2).0, &mut (tup.0).2);
swap(&mut (tup.1).2, &mut (tup.2).1);
}
fn main() {
let mut count_hor = 0;
let mut count_ver = 0;
let mut cache = ((0,0,0),(0,0,0),(0,0,0));
let mut cachen = 0;
for line in BufReader::new(stdin()).... | code_fim | hard | {
"lang": "rust",
"repo": "Taneb/AoC",
"path": "/aoc3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thepwagner/dependagot path: /rust/cargo/src/handlers/files.rs
use crate::state::State;
use dependagot_common;
use std::str;
/// Files()
pub async fn files(
req: dependagot_common::FilesRequest,
state: State,
) -> Result<impl warp::Reply, std::convert::Infallible> {
let mut files = s... | code_fim | medium | {
"lang": "rust",
"repo": "thepwagner/dependagot",
"path": "/rust/cargo/src/handlers/files.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut optional_paths = vec![];
if !files.contains_key("Cargo.lock") {
optional_paths.push("Cargo.lock".to_string());
}
let res = dependagot_common::FilesResponse {
required_paths,
optional_paths,
};
Ok(warp_protobuf::reply::protobuf(&res))
}<|fim_prefix|>/... | code_fim | medium | {
"lang": "rust",
"repo": "thepwagner/dependagot",
"path": "/rust/cargo/src/handlers/files.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if count_same == 1 || adj_same {
count += 1;
}
}
println!("{}", count);
}<|fim_prefix|>// repo: Quetute/AdventOfCode path: /2019/aoc04/src/main.rs
fn main() {
let min = 372037;
let max = 905157;
let mut count = 0;
'outer: for i in min..=max {
... | code_fim | hard | {
"lang": "rust",
"repo": "Quetute/AdventOfCode",
"path": "/2019/aoc04/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Quetute/AdventOfCode path: /2019/aoc04/src/main.rs
fn main() {
let min = 372037;
let max = 905157;
let mut count = 0;
'outer: for i in min..=max {
let s = i.to_string();
let mut s = s.chars();
let mut prev = s.next().unwrap();
let mut adj_same = ... | code_fim | hard | {
"lang": "rust",
"repo": "Quetute/AdventOfCode",
"path": "/2019/aoc04/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>is_prime(*x)).nth(n as usize).unwrap_or(0)
}<|fim_prefix|>// repo: jasonliang-dev/exercism path: /rust/nth-prime/src/lib.rs
pub fn nth(n: u32) -> u32 {
let is_prime = |n| !(2..(n as f32).sqrt() as u32 + 1).<|fim_middle|>any(|i| n % i == 0);
(2..).filter(|x| | code_fim | easy | {
"lang": "rust",
"repo": "jasonliang-dev/exercism",
"path": "/rust/nth-prime/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jasonliang-dev/exercism path: /rust/nth-prime/src/lib.rs
pub fn nth(n: u32) -> u32 {
let is_prime = |n| !(2..(n as f32).sqrt() as u32 + 1).<|fim_suffix|>is_prime(*x)).nth(n as usize).unwrap_or(0)
}<|fim_middle|>any(|i| n % i == 0);
(2..).filter(|x| | code_fim | easy | {
"lang": "rust",
"repo": "jasonliang-dev/exercism",
"path": "/rust/nth-prime/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Elbehery/arrow path: /rust/arrow/examples/builders.rs
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this fi... | code_fim | medium | {
"lang": "rust",
"repo": "Elbehery/arrow",
"path": "/rust/arrow/examples/builders.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create a new builder with a capacity of 100
let mut primitive_array_builder = Int32Builder::new(100);
// Append an individual primitive value
primitive_array_builder.append_value(55).unwrap();
// Append a null value
primitive_array_builder.append_null().unwrap();
// Appen... | code_fim | hard | {
"lang": "rust",
"repo": "Elbehery/arrow",
"path": "/rust/arrow/examples/builders.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mi-yu/firecracker path: /src/vm-memory/src/lib.rs
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Portions Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style li... | code_fim | medium | {
"lang": "rust",
"repo": "mi-yu/firecracker",
"path": "/src/vm-memory/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod bytes;
mod guest_address;
mod guest_memory;
mod mmap;
pub use bytes::{ByteValued, Bytes};
pub use guest_address::Address;
pub use guest_address::GuestAddress;
pub use guest_memory::Error as GuestMemoryError;
pub use guest_memory::GuestMemory;
pub use guest_memory::MemoryRegion;
pub use mmap::{Error a... | code_fim | medium | {
"lang": "rust",
"repo": "mi-yu/firecracker",
"path": "/src/vm-memory/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use bytes::{ByteValued, Bytes};
pub use guest_address::Address;
pub use guest_address::GuestAddress;
pub use guest_memory::Error as GuestMemoryError;
pub use guest_memory::GuestMemory;
pub use guest_memory::MemoryRegion;
pub use mmap::{Error as MemoryMappingError, MemoryMapping};<|fim_prefix|>// repo:... | code_fim | medium | {
"lang": "rust",
"repo": "mi-yu/firecracker",
"path": "/src/vm-memory/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut peer = match Peer::new(PeerInitialize {
torrent_id,
socket,
pieces_infos,
supervisor,
extern_id,
consumer,
fs,
buffers,
})
.await
... | code_fim | hard | {
"lang": "rust",
"repo": "sebastiencs/rustorrent",
"path": "/src/torrent.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if peer.shared.nbytes_on_tasks.load(Acquire) < tasks_nbytes / 2 {
let available = peer.queue_tasks.available().saturating_sub(1);
if let Some((nbytes, tasks)) = self.piece_picker.pick_piece(
id,
tasks_... | code_fim | hard | {
"lang": "rust",
"repo": "sebastiencs/rustorrent",
"path": "/src/torrent.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sebastiencs/rustorrent path: /src/torrent.rs
use async_channel::{bounded, Receiver, Sender};
use crossbeam_channel::Sender as SyncSender;
use hashbrown::HashSet;
use std::sync::{
atomic::{
AtomicUsize,
Ordering::{self, Acquire, Relaxed},
},
Arc,
};
// use log::info;
u... | code_fim | hard | {
"lang": "rust",
"repo": "sebastiencs/rustorrent",
"path": "/src/torrent.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_problem_004() {
assert_eq!(euler_004(), 906609);
}
}<|fim_prefix|>// repo: agude/Project-Euler-Rust path: /src/bin/problem_004.rs
/*
* A palindromic number reads the same both ways. The largest palindrome made from the prod... | code_fim | hard | {
"lang": "rust",
"repo": "agude/Project-Euler-Rust",
"path": "/src/bin/problem_004.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agude/Project-Euler-Rust path: /src/bin/problem_004.rs
/*
* A palindromic number reads the same both ways. The largest palindrome made from the product of
* two 2-digit numbers is 9009 = 91 x 99.
*
* Find the largest palindrome made from the product of two 3-digit numbers.
*/
extern crate p... | code_fim | medium | {
"lang": "rust",
"repo": "agude/Project-Euler-Rust",
"path": "/src/bin/problem_004.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tesuji/rust_inline_bug path: /src/y2015/day_01.rs
pub fn solve(){
const INPUT : &str = include_str!("../../inputs/2015/1");
let mut floor = 0;
let mut was_in_the_basement = false;
for (position,<|fim_suffix|> position + 1); // 1 based index
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "tesuji/rust_inline_bug",
"path": "/src/y2015/day_01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> position + 1); // 1 based index
}
}
_ => unreachable!()
}
}
println!("[PART 1] Target floor {}", floor);
}<|fim_prefix|>// repo: tesuji/rust_inline_bug path: /src/y2015/day_01.rs
pub fn solve(){
const INPUT : &str = include_str!("../../inputs... | code_fim | hard | {
"lang": "rust",
"repo": "tesuji/rust_inline_bug",
"path": "/src/y2015/day_01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luke-titley/imgui-docking-rs path: /src/widget/tab.rs
//! Safe wrapper around imgui-sys for tab menu.
//!
//! # Examples
//
//! ```no_run
//! # use imgui::*;
//! # let mut ctx = Context::create();
//! # let ui = ctx.frame();
//!
//! // During UI construction
//! TabBar::new(im_str!("tabbar")).... | code_fim | hard | {
"lang": "rust",
"repo": "luke-titley/imgui-docking-rs",
"path": "/src/widget/tab.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Will open or close the tab.\
///
/// True to display the tab. Tab item is visible by default.
#[inline]
pub fn opened(mut self, opened: &'a mut bool) -> Self {
self.opened = Some(opened);
self
}
/// Set the flags of the tab item.
///
/// Flags are e... | code_fim | hard | {
"lang": "rust",
"repo": "luke-titley/imgui-docking-rs",
"path": "/src/widget/tab.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vitorenesduarte/pluscal-rs path: /src/module.rs
use crate::label::Label;
use crate::var::{NaturalVar, NaturalVarBuilder};
use crate::ToPlusCal;
use std::collections::HashSet;
pub struct Module {
name: String,
extends: Vec<String>,
vars: HashSet<String>,
pub(crate) natural_vars: ... | code_fim | hard | {
"lang": "rust",
"repo": "vitorenesduarte/pluscal-rs",
"path": "/src/module.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variables.push(crate::NEW_LINE);
variables.push_str(&declarations);
variables.push(';');
lines.push(variables);
}
lines.push(String::new());
lines.push(String::from("begin"));
lines.push(self.root.to_pluscal(0));
lin... | code_fim | hard | {
"lang": "rust",
"repo": "vitorenesduarte/pluscal-rs",
"path": "/src/module.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kezenator/adventofcode path: /2020/src/y2019/d08/mod.rs
use crate::support::*;
const INPUT: &str = include_str!("input.txt");
// ** ** **** * ***
// * * * * * * *
// * * * * * *
// * * * * ***
// * * * * * * *
// ** ** **** **** *... | code_fim | hard | {
"lang": "rust",
"repo": "kezenator/adventofcode",
"path": "/2020/src/y2019/d08/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
get_1_x_2_for_min_0(INPUT, 25, 6)
}
fn part_2() -> String
{
render_image(INPUT, 25, 6)
}
pub fn puzzles() -> PuzzleDay
{
puzzle_day(8)
.example(|| Answer {
calculated: get_1_x_2_for_min_0("123456789012", 3, 2),
expected: 1,
})
... | code_fim | hard | {
"lang": "rust",
"repo": "kezenator/adventofcode",
"path": "/2020/src/y2019/d08/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: larstobi/jmap-rs path: /src/calendar.rs
use rustc_serialize::json::{Json, ToJson};
use std::collections::BTreeMap;
use std::default::Default;
use std::string::ToString;
<|fim_suffix|>make_record_type!(Calendar, PartialCalendar, "Calendar",
name: String => "name",
color: ... | code_fim | medium | {
"lang": "rust",
"repo": "larstobi/jmap-rs",
"path": "/src/calendar.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>make_record_type!(Calendar, PartialCalendar, "Calendar",
name: String => "name",
color: String => "color", // XXX CSS colour type?
sort_order: u64 => "sortOrder",
is_visible: bool => "isVisible",
may_read_free_busy: bool => "mayReadFree... | code_fim | medium | {
"lang": "rust",
"repo": "larstobi/jmap-rs",
"path": "/src/calendar.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Guppster/Daily path: /easy/[#227] Square Spirals/SquareSpirals/src/main.rs
use std::io::prelude::*;
use std::io::{Lines,BufReader};
use std::fs::File;
use std::path::Path;
use std::str::FromStr;
use std::ops::Div;
fn squared(x: u64) -> u64 {
x*x
}
/// Calculate ring of specified index
fn r... | code_fim | hard | {
"lang": "rust",
"repo": "Guppster/Daily",
"path": "/easy/[#227] Square Spirals/SquareSpirals/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let v2 = values.next();
if v2.is_some() {
println!("{:?}", coord_to_index(v1, parse_value(v2.unwrap()), size));
} else {
println!("{:?}", index_to_coord(v1, size));
}
}
fn parse_lines(input: &mut std::io::Lines<std::io::BufReader<File>>) {
parse_input(
&input.... | code_fim | hard | {
"lang": "rust",
"repo": "Guppster/Daily",
"path": "/easy/[#227] Square Spirals/SquareSpirals/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Convert a coordinate to an index for the specified grid size
fn coord_to_index(x: u64, y: u64, size: u64) -> u64 {
let center = (size + 1) / 2;
let dx = (x as i64) - (center as i64);
let dy = (y as i64) - (center as i64);
let ring = std::cmp::max(dx.abs(), dy.abs());
if ring == 0 ... | code_fim | hard | {
"lang": "rust",
"repo": "Guppster/Daily",
"path": "/easy/[#227] Square Spirals/SquareSpirals/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod config;
pub mod network;
pub mod api;
pub mod crypto;
pub mod primitive;
pub mod db;
pub mod blockchain;
pub mod contract;
pub mod experiment;
pub mod mempool;
pub mod cmtda;
pub mod mainChainManager;<|fim_prefix|>// repo: simplespy/ACeD path: /src/lib.rs
#[macro_use]
extern crate log;
extern cr... | code_fim | easy | {
"lang": "rust",
"repo": "simplespy/ACeD",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simplespy/ACeD path: /src/lib.rs
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate rand;
#[macro_use(lazy_static)]
extern crate lazy_static;
extern crate serialization as ser;
<|fim_suffix|>pub mod config;
pub mod network;
pub mod api;
pub mod crypto;
pub mod primitive;
pub ... | code_fim | easy | {
"lang": "rust",
"repo": "simplespy/ACeD",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use $crate::avm1::test_utils::*;
$(
for version in &$versions {
with_avm(*version, |activation, _root| -> Result<(), Error> {
let object = $object(activation);
let function = object.get($name, activ... | code_fim | hard | {
"lang": "rust",
"repo": "acidburn0zzz/ruffle",
"path": "/core/src/avm1/test_utils.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let globals = avm1.global_object_cell();
let mut context = UpdateContext {
gc_context,
player_version: 32,
swf: &swf,
levels: &mut levels,
rng: &mut SmallRng::from_seed([0u8; 16]),
audio: &mut NullAudioBackend::new(),... | code_fim | hard | {
"lang": "rust",
"repo": "acidburn0zzz/ruffle",
"path": "/core/src/avm1/test_utils.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acidburn0zzz/ruffle path: /core/src/avm1/test_utils.rs
use crate::avm1::activation::{Activation, ActivationIdentifier};
use crate::avm1::error::Error;
use crate::avm1::globals::system::SystemProperties;
use crate::avm1::{Avm1, Object, Timers, UpdateContext};
use crate::avm2::Avm2;
use crate::bac... | code_fim | hard | {
"lang": "rust",
"repo": "acidburn0zzz/ruffle",
"path": "/core/src/avm1/test_utils.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iPersona/algorithm path: /src/sort/quick.rs
use std::cmp::{PartialEq, PartialOrd};
// use std::clone::Clone;
pub fn quick_sort<T: PartialEq + PartialOrd>(source: &mut Vec<T>) {
if (*source).len() <= 1 {
return
}
let base = (*source).pop().unwrap();
<|fim_suffix|> let mu... | code_fim | hard | {
"lang": "rust",
"repo": "iPersona/algorithm",
"path": "/src/sort/quick.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let v = (*source).pop().unwrap();
if v < base {
less.push(v);
} else {
greater.push(v);
}
}
let mut sort_array = Vec::new();
quick_sort(&mut less);
quick_sort(&mut greater);
sort_array.append(&mut less);
sort_array.push(b... | code_fim | medium | {
"lang": "rust",
"repo": "iPersona/algorithm",
"path": "/src/sort/quick.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: defuse/ziggurat path: /src/tools/metrics/recorder.rs
//! Metrics recording types and utilites.
use std::{collections::HashMap, sync::Arc};
use metrics::{GaugeValue, Key, SetRecorderError, Unit};
use parking_lot::Mutex;
/// A counter metric.
#[derive(Default)]
pub struct Counter {
pub valu... | code_fim | hard | {
"lang": "rust",
"repo": "defuse/ziggurat",
"path": "/src/tools/metrics/recorder.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Enables the [`SimpleRecorder`] as the
/// [`metrics::Recorder`](https://docs.rs/metrics/0.16.0/metrics/trait.Recorder.html) sink.
pub fn enable_simple_recorder() -> Result<(), SetRecorderError> {
// FIXME: This is a work-around while we don't have a test-runner
// which can set this glo... | code_fim | hard | {
"lang": "rust",
"repo": "defuse/ziggurat",
"path": "/src/tools/metrics/recorder.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn record_histogram(&self, key: &Key, value: f64) {
assert!(value.is_sign_positive());
assert!(value.is_finite());
if let Some(histogram) = self.histograms.lock().get_mut(key) {
// We know it cannot be negative, NaN or infinite so this is safe (albeit lossy)
... | code_fim | hard | {
"lang": "rust",
"repo": "defuse/ziggurat",
"path": "/src/tools/metrics/recorder.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..num {
res += (b - a) / 2.0 * w[i] * func(p2v(x[i], a, b));
}
return res;
}<|fim_prefix|>// repo: Rilord/sem_iv_algos path: /lab5/src/gauss/mod.rs
extern crate peroxide;
fn p2v(p: f64, c: f64, d: f64) -> f64 {
return (d + c) / 2.0 + (d - c) * p / 2.0;
}
pub fn gau... | code_fim | medium | {
"lang": "rust",
"repo": "Rilord/sem_iv_algos",
"path": "/lab5/src/gauss/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rilord/sem_iv_algos path: /lab5/src/gauss/mod.rs
extern crate peroxide;
fn p2v(p: f64, c: f64, d: f64) -> f64 {
<|fim_suffix|> for i in 0..num {
res += (b - a) / 2.0 * w[i] * func(p2v(x[i], a, b));
}
return res;
}<|fim_middle|> return (d + c) / 2.0 + (d - c) * p / 2.0; ... | code_fim | hard | {
"lang": "rust",
"repo": "Rilord/sem_iv_algos",
"path": "/lab5/src/gauss/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut current_point = point::Point::new(point_1.x, point_1.y);
let mut counter = 0;
let mut x: i32 = current_point.x as i32;
let mut y: i32 = current_point.y as i32;
loop {
if x == point_2.x as i32 && y == point_2.y as i32 {
return t... | code_fim | hard | {
"lang": "rust",
"repo": "superosku/oskuRTS",
"path": "/src/map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: superosku/oskuRTS path: /src/map.rs
use std::mem::transmute;
use super::point;
use super::noise;
use super::binary_helpers::Binaryable;
use super::binary_helpers;
#[derive(Copy, Clone, PartialEq)]
pub enum GroundType {
Empty,
Grass,
Water,
// Forest,
Sand,
Rock,
//... | code_fim | hard | {
"lang": "rust",
"repo": "superosku/oskuRTS",
"path": "/src/map.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: autarch/edgedb-rust path: /edgedb-client/examples/list_databases.rs
use std::error::Error;
use async_std::task;
fn main() -> Result<(), Box<dyn Error>> {
<|fim_suffix|> let databases: Vec<String> = task::block_on(async {
let pool = edgedb_client::connect().await?;
pool.query(... | code_fim | easy | {
"lang": "rust",
"repo": "autarch/edgedb-rust",
"path": "/edgedb-client/examples/list_databases.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> env_logger::init();
let databases: Vec<String> = task::block_on(async {
let pool = edgedb_client::connect().await?;
pool.query("SELECT name := sys::Database.name", &()).await
})?;
println!("Database list:");
for db in databases {
println!("{}", db);
}
O... | code_fim | easy | {
"lang": "rust",
"repo": "autarch/edgedb-rust",
"path": "/edgedb-client/examples/list_databases.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kirinse/seed_heroicons path: /src/solid/document_remove.rs
use seed::{prelude::*, *};
use super::{solid_trait_private::SolidPrivate, Solid};
pub struct DocumentRemove;
<|fim_suffix|> svg![
C![classes],
attrs!(
At::from("fill") => "currentColor",
... | code_fim | medium | {
"lang": "rust",
"repo": "kirinse/seed_heroicons",
"path": "/src/solid/document_remove.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SolidPrivate for DocumentRemove {
fn base<T>(classes: impl ToClasses) -> Node<T> {
svg![
C![classes],
attrs!(
At::from("fill") => "currentColor",
At::from("viewBox") => "0 0 20 20",
),
path![attrs!(
At::fr... | code_fim | medium | {
"lang": "rust",
"repo": "kirinse/seed_heroicons",
"path": "/src/solid/document_remove.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gbip/stm32f429x path: /src/ethernet_dma/dmaier/mod.rs
inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
{
let bits = self.register.get();
let r = R { bits: bits };
let mut w = W { bits: bits };
f... | code_fim | hard | {
"lang": "rust",
"repo": "gbip/stm32f429x",
"path": "/src/ethernet_dma/dmaier/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gbip/stm32f429x path: /src/ethernet_dma/dmaier/mod.rs
er"]
pub struct W {
bits: u32,
}
impl super::Dmaier {
#[doc = r" Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
{
... | code_fim | hard | {
"lang": "rust",
"repo": "gbip/stm32f429x",
"path": "/src/ethernet_dma/dmaier/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> MASK: u8 = 1;
const OFFSET: u8 = 9;
((self.bits >> OFFSET) & MASK as u32) as u8
};
RwtieR { bits }
}
#[doc = "Bit 10 - no description available"]
#[inline(always)]
pub fn etie(&self) -> EtieR {
let bits = {
const MASK: u8 = 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "gbip/stm32f429x",
"path": "/src/ethernet_dma/dmaier/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlterionX/benxu-dev path: /blog-client/src/locations.rs
use seed::prelude::*;
use serde::{Deserialize, Serialize};
use crate::{
messages::{AsyncM as GlobalAsyncM, M as GlobalM},
model::{Store as GlobalS, StoreOperations as GSOp},
};
pub mod editor;
pub mod listing;
pub mod login;
pub m... | code_fim | hard | {
"lang": "rust",
"repo": "AlterionX/benxu-dev",
"path": "/blog-client/src/locations.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn view(loc: &Location, gs: &GlobalS) -> Vec<Node<GlobalM>> {
match loc {
Location::Logout => vec![h1!["Logging out..."]],
Location::Listing(s) => listing::render(s, gs).map_msg(M::Listing),
Location::Login(s) => vec![login::render(s, gs).map_msg(M::Login)],
Locatio... | code_fim | hard | {
"lang": "rust",
"repo": "AlterionX/benxu-dev",
"path": "/blog-client/src/locations.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "virtual to physical translation error"
}
fn cause(&self) -> Option<&dyn Error> {
None
}
}
fn chunked(start: Gva, sz: usize) -> impl Iterator<Item = (Gva, usize)> {
debug_assert!(start.checked_add(sz as u64).is_some());
let mut remaining = sz;
let mut base = star... | code_fim | hard | {
"lang": "rust",
"repo": "quarkslab/whvp",
"path": "/whvp-core/src/mem.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quarkslab/whvp path: /whvp-core/src/mem.rs
use std::error::Error;
use std::fmt;
use std::iter;
use std::mem;
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use fnv::FnvHasher;
use anyhow::Result;
pub type FastMap64<K, V> = HashMap<K, V, BuildHasherDefault<FnvHasher>>;
pub... | code_fim | hard | {
"lang": "rust",
"repo": "quarkslab/whvp",
"path": "/whvp-core/src/mem.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_oui_set(ip_to_dhcpd_lease: &IPToDhcpdLease) -> OuiSet {
let mut oui_set = OuiSet::default();
for dhcpd_lease in ip_to_dhcpd_lease.values() {
if let Some(ref mac) = dhcpd_lease.mac {
oui_set.insert(mac_to_oui(mac));
}
}
oui_set
}
fn read_oui_file(mut ou... | code_fim | hard | {
"lang": "rust",
"repo": "aaronriekenberg/rust-dhcp-leases",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match str_to_oui(&line_string[0..6]) {
Ok(oui) => {
if oui_set.remove(&oui) {
let organization = &line_string[22..];
oui_to_organization.insert(oui, organization.to_string());
}
... | code_fim | hard | {
"lang": "rust",
"repo": "aaronriekenberg/rust-dhcp-leases",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aaronriekenberg/rust-dhcp-leases path: /src/main.rs
use chrono::prelude::{DateTime, Local, TimeZone, Utc};
use enum_map::{enum_map, EnumMap};
use fnv::FnvHashMap;
use fnv::FnvHashSet;
use std::borrow::Cow;
use std::default::Default;
use std::fs::File;
use std::io::BufRead;
use std::io::BufRea... | code_fim | hard | {
"lang": "rust",
"repo": "aaronriekenberg/rust-dhcp-leases",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cedelmaier/primeSieveProjects path: /primes/primes.rs/src/main.rs
/// Eratosthenes prime sieve program
extern crate num;
fn main() {
// Read the input number directly, but need the limit binding
// occur so that the compiler can infer the type
let input_num =
std::env::args... | code_fim | hard | {
"lang": "rust",
"repo": "cedelmaier/primeSieveProjects",
"path": "/primes/primes.rs/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lmtbf = (f64::floor((limit as f64) / 30.0) * 8.0 - 1.0) as usize;
let lmtsqrt_index = f64::sqrt(limit as f64) as usize - 7;
let lmtsqrt = (f64::floor((lmtsqrt_index as f64) / 30.0) as usize) * 8 + ndxs[lmtsqrt_index %
30];
let mut primes = vec![true; lmtbf+1];
for i in 0.... | code_fim | hard | {
"lang": "rust",
"repo": "cedelmaier/primeSieveProjects",
"path": "/primes/primes.rs/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let climit = lmtbf - 6 + ndxs[(limit - 7) % 30];
(0..climit).fold((3,7), |(count, max), prime| {
if primes[prime] {
(count + 1, (30*(prime>>3) + mod_primes[prime&7]) as u64)
} else {
(count, max)
}
})
}<|fim_prefix|>// repo: cedelmaier/primeSieve... | code_fim | hard | {
"lang": "rust",
"repo": "cedelmaier/primeSieveProjects",
"path": "/primes/primes.rs/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jblebrun/wrausmt path: /src/format/text/token.rs
use crate::format::Location;
use super::string::WasmString;
/// A [Token] along with context about its location in the source file.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct FileToken {
pub token: Token,
pub location: Locati... | code_fim | hard | {
"lang": "rust",
"repo": "jblebrun/wrausmt",
"path": "/src/format/text/token.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for Token {
/// Returns a default token of [Token::Start].
fn default() -> Token {
Token::Start
}
}
impl Location {
/// Create a new [FileToken] from this [Location] for the provided [Token].
pub fn token(self, token: Token) -> FileToken {
FileToken {
... | code_fim | hard | {
"lang": "rust",
"repo": "jblebrun/wrausmt",
"path": "/src/format/text/token.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mimerme/purgatory path: /atory/src/rebuild.rs
use glsl::syntax::FunctionParameterDeclaration::Named;
use glsl::syntax::StorageQualifier::Out;
use glsl::syntax::TypeQualifierSpec::Storage;
use glsl::{
parser::Parse,
syntax::{
Declaration, ExternalDeclaration, FullySpecifiedType, F... | code_fim | hard | {
"lang": "rust",
"repo": "Mimerme/purgatory",
"path": "/atory/src/rebuild.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> begin
}
pub fn parse(root: TranslationUnit) -> TranslationUnit {
match root {
TranslationUnit(root_declarations) => {
/// NOTE: this is not scalable at anything more compilcated than a single file i thinks
/// Loop until we we find the main_image() def and then pas... | code_fim | hard | {
"lang": "rust",
"repo": "Mimerme/purgatory",
"path": "/atory/src/rebuild.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: neosam/textgame path: /src/holder.rs
use std::marker::PhantomData;
#[derive(Serialize, Deserialize, Debug, Default)]
pub struct Holder<T, K: HolderKey> {
pub items: Vec<T>,
pub phantom: PhantomData<K>
}
pub trait HolderKey {
fn new(usize) -> Self;
<|fim_suffix|> fn get(... | code_fim | hard | {
"lang": "rust",
"repo": "neosam/textgame",
"path": "/src/holder.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T, K: HolderKey> Holder<T, K> {
pub fn add(&mut self, item: T) -> K {
let res = self.items.len();
self.items.push(item);
HolderKey::new(res)
}
pub fn get(&self, i: K) -> &T {
self.items.get(i.get()).unwrap()
}
pub fn get_mut(&mut self, i: K) -> &m... | code_fim | medium | {
"lang": "rust",
"repo": "neosam/textgame",
"path": "/src/holder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Venats/advent_of_code_2018 path: /src/bin/day5.rs
extern crate advent_of_code_2018;
use std::fs::File;
use std::io::prelude::*;
fn reacting(a: char, b: char) -> bool {
<|fim_suffix|>fn main() {
let mut f = File::open("./data/day5.txt").expect("file not found");
let mut input = String::n... | code_fim | hard | {
"lang": "rust",
"repo": "Venats/advent_of_code_2018",
"path": "/src/bin/day5.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
input.chars().fold(vec!(), |mut stack, b| match stack.last() {
_ if skip == Some(b.to_ascii_lowercase()) => stack,
Some(&c) if reacting(b,c) => {stack.pop(); stack},
_ => {stack.push(b); stack},
}).len()
}
fn main() {
let mut f = File::op... | code_fim | medium | {
"lang": "rust",
"repo": "Venats/advent_of_code_2018",
"path": "/src/bin/day5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theduke/translator path: /backend/src/db/schema/translation.rs
use uuid::Uuid;
use super::key::keys;
table!(
translations {
id -> Text,
language_id -> Text,
key_id -> Text,
version -> Int4,
value -> Text,
created_at -> BigInt,
updated_at -> BigInt,
created_by ... | code_fim | hard | {
"lang": "rust",
"repo": "theduke/translator",
"path": "/backend/src/db/schema/translation.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Insertable, Queryable, AsChangeset,
Serialize, Deserialize, Debug, Clone)]
#[table_name="translations"]
pub struct Translation {
pub id: String,
pub language_id: String,
pub key_id: String,
pub version: i32,
pub value: String,
pub created_at: i64,
pub updated_at: i64,
... | code_fim | medium | {
"lang": "rust",
"repo": "theduke/translator",
"path": "/backend/src/db/schema/translation.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> input!(n: usize, mut a: [i64; n]);
a.sort();
let ca = a.iter().cumsum().collect::<Vec<i64>>();
let mut ans = 0;
for i in 0..n-1 {
ans += (ca[n-1]-ca[i]) - ((n - i - 1) as i64) * a[i];
}
println!("{}", ans);
}<|fim_prefix|>// repo: Shirataki2/competitive_submissions pat... | code_fim | easy | {
"lang": "rust",
"repo": "Shirataki2/competitive_submissions",
"path": "/abc186/src/bin/d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shirataki2/competitive_submissions path: /abc186/src/bin/d.rs
#![allow(unused_imports)]
use proconio::{input, fastout};
use itertools_num::ItertoolsNum as _;
use std::cmp::*;
<|fim_suffix|> input!(n: usize, mut a: [i64; n]);
a.sort();
let ca = a.iter().cumsum().collect::<Vec<i64>>();... | code_fim | easy | {
"lang": "rust",
"repo": "Shirataki2/competitive_submissions",
"path": "/abc186/src/bin/d.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tntmeijs/aoc_2020 path: /aoc/src/main.rs
mod invalid_puzzle;
use invalid_puzzle::InvalidPuzzle;
use day_01::solution::Day01;
use day_02::solution::Day02;
use day_03::solution::Day03;
use day_04::solution::Day04;
use day_05::solution::Day05;
use day_06::solution::Day06;
use day_07::solution::Day... | code_fim | hard | {
"lang": "rust",
"repo": "tntmeijs/aoc_2020",
"path": "/aoc/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut puzzle_index = parse_result.unwrap();
if puzzle_index == 0 || puzzle_index > 25 {
panic!("Invalid puzzle day specified, please use a number (u32) between 1 and 25");
}
if !puzzles.contains_key(&puzzle_index) {
puzzle_index = 0;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "tntmeijs/aoc_2020",
"path": "/aoc/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let answer = run_program(&samples_n_program);
assert_eq!(answer, Register::from([681, 681, 3, 0]));
}
}<|fim_prefix|>// repo: haraldmaida/advent-of-code-2018 path: /src/day16/tests.rs
use super::*;
const INPUT: &str = include_str!("../../input/2018/day16.txt");
const EXAMPLE1_INPUT... | code_fim | hard | {
"lang": "rust",
"repo": "haraldmaida/advent-of-code-2018",
"path": "/src/day16/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let samples_n_program = parse(INPUT).unwrap();
let answer = num_samples_behaving_like_three_or_more_opcodes(&samples_n_program);
assert_eq!(answer, 646);
}
}
mod part2 {
use super::*;
#[test]
fn answer() {
let samples_n_program = parse(INPUT).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "haraldmaida/advent-of-code-2018",
"path": "/src/day16/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: haraldmaida/advent-of-code-2018 path: /src/day16/tests.rs
use super::*;
const INPUT: &str = include_str!("../../input/2018/day16.txt");
const EXAMPLE1_INPUT: &str = "\
Before: [3, 2, 1, 1]
9 2 1 2
After: [3, 2, 2, 1]
";
<|fim_suffix|> #[test]
fn example1() {
let (samples, inst... | code_fim | medium | {
"lang": "rust",
"repo": "haraldmaida/advent-of-code-2018",
"path": "/src/day16/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: synlestidae/rust-jvm path: /src/classfile/info.rs
use classfile::attribute::Attribute;
use classfile::access_fl<|fim_suffix|>pub descriptor: String,
pub attributes: Vec<Attribute>,
}<|fim_middle|>ags::AccessFlags;
#[derive(Debug, Clone)]
pub struct Info {
pub access_flags: AccessFlags,
... | code_fim | medium | {
"lang": "rust",
"repo": "synlestidae/rust-jvm",
"path": "/src/classfile/info.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub descriptor: String,
pub attributes: Vec<Attribute>,
}<|fim_prefix|>// repo: synlestidae/rust-jvm path: /src/classfile/info.rs
use classfile::attribute::Attribute;
use classfile::access_fl<|fim_middle|>ags::AccessFlags;
#[derive(Debug, Clone)]
pub struct Info {
pub access_flags: AccessFlags,
... | code_fim | medium | {
"lang": "rust",
"repo": "synlestidae/rust-jvm",
"path": "/src/classfile/info.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Connect to the DriverHostDevelopment Protocol protocol.
let service = connect_to_protocol::<DriverHostDevelopmentMarker>()
.context("Failed to connect to development protocol")?;
// Make request to devcoordinator to restart driver hosts.
let res = service.restart_driver_hosts(&... | code_fim | medium | {
"lang": "rust",
"repo": "dreamboy9/fuchsia",
"path": "/src/devices/bin/restart-driver-hosts/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dreamboy9/fuchsia path: /src/devices/bin/restart-driver-hosts/src/main.rs
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use anyhow::{Context as _, Error};
use fidl_fuchsia_devic... | code_fim | hard | {
"lang": "rust",
"repo": "dreamboy9/fuchsia",
"path": "/src/devices/bin/restart-driver-hosts/src/main.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Make request to devcoordinator to restart driver hosts.
let res = service.restart_driver_hosts(&opt.driver_path).await?;
println!("{:?}", res);
Ok(())
}<|fim_prefix|>// repo: dreamboy9/fuchsia path: /src/devices/bin/restart-driver-hosts/src/main.rs
// Copyright 2021 The Fuchsia Author... | code_fim | hard | {
"lang": "rust",
"repo": "dreamboy9/fuchsia",
"path": "/src/devices/bin/restart-driver-hosts/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let full_name = format!("{fname} {lname}");
println!("{full_name}");
dbg!(full_name);
}<|fim_prefix|>// repo: szabgab/slides path: /rust/examples/intro/print.rs
fn main() {
let fname = "Foo";
let lname = "Bar";
<|fim_middle|> println!("{} {}", fname, lname);
println!("{fname} ... | code_fim | medium | {
"lang": "rust",
"repo": "szabgab/slides",
"path": "/rust/examples/intro/print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> eprintln!("error in {} {}", fname, lname);
eprint!("error in {} {}\n", fname, lname);
let full_name = format!("{fname} {lname}");
println!("{full_name}");
dbg!(full_name);
}<|fim_prefix|>// repo: szabgab/slides path: /rust/examples/intro/print.rs
fn main() {
let fname = "Foo";
... | code_fim | medium | {
"lang": "rust",
"repo": "szabgab/slides",
"path": "/rust/examples/intro/print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: szabgab/slides path: /rust/examples/intro/print.rs
fn main() {
let fname = "Foo";
let lname = "Bar";
<|fim_suffix|> eprintln!("error in {} {}", fname, lname);
eprint!("error in {} {}\n", fname, lname);
let full_name = format!("{fname} {lname}");
println!("{full_name}");
... | code_fim | medium | {
"lang": "rust",
"repo": "szabgab/slides",
"path": "/rust/examples/intro/print.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl std::fmt::Display for RpcWarning {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
use RpcWarning::*;
match self {
Println(..) => write!(f, "`println!` writes to the service output channel. If you meant to log debugging information, use `eprintln!` or ... | code_fim | hard | {
"lang": "rust",
"repo": "IamthatIam777/oasis-rs",
"path": "/oasis-build/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IamthatIam777/oasis-rs path: /oasis-build/src/error.rs
use rustc_ast_pretty::pprust;
use rustc_span::{MultiSpan, Span};
// NB: `failure` won't work on these errors because `Span` isn't `Send`.
pub struct UnsupportedTypeError {
pub type_name: String,
pub span: Span,
}
impl std::fmt::Di... | code_fim | hard | {
"lang": "rust",
"repo": "IamthatIam777/oasis-rs",
"path": "/oasis-build/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.