text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> println!("Enter a number: ");
let mut number = String::new();
std::io::stdin().read_line(&mut number)
.expect("Error reading input.");
let number : u32 = number.trim().parse()
.expect("Invalid number.");
println!("{}th fibonacci's number is: {}", number, fib(number));
... | code_fim | medium | {
"lang": "rust",
"repo": "vrbala/rust-learn",
"path": "/branches/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let config = Config::from_args();
workers(config)
}<|fim_prefix|>// repo: crodjer/disturbance path: /src/main.rs
use disturbance::config::Config;
use disturbance::worker::workers;
use failure::Error;
use structopt::StructOpt;
<|fim_middle|>fn main() -> Result<(), Error> {
| code_fim | easy | {
"lang": "rust",
"repo": "crodjer/disturbance",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crodjer/disturbance path: /src/main.rs
use disturbance::config::Config;
use disturbance::worker::workers;
use failure::Error;
use structopt::StructOpt;
<|fim_suffix|> let config = Config::from_args();
workers(config)
}<|fim_middle|>fn main() -> Result<(), Error> {
| code_fim | easy | {
"lang": "rust",
"repo": "crodjer/disturbance",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hongweixiao/for_offer path: /src/find_path_026.rs
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
val: i32,
left: Option<Rc<RefCell<TreeNode>>>,
right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
#[inline]
pub fn new(val: ... | code_fim | hard | {
"lang": "rust",
"repo": "hongweixiao/for_offer",
"path": "/src/find_path_026.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result: Vec<Vec<i32>> = vec!();
if root.is_none() {
return result;
}
let list: Vec<i32> = vec!();
find(root, target, 0, list, &mut result);
return result;
}
fn find(node: Option<Rc<RefCell<TreeNode>>>, target: i32, mut sum: i32,
... | code_fim | hard | {
"lang": "rust",
"repo": "hongweixiao/for_offer",
"path": "/src/find_path_026.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng = rand::thread_rng();
let seed = "which case is this";
let case_outputs = [
(Case::Camel, "whichCaseIsThis"),
// (Case::Class, "WhichCaseIsThis"),
(Case::Kebab, "which-case-is-this"),
(Case::Lower, "which case is this"),
... | code_fim | hard | {
"lang": "rust",
"repo": "b-r-oleary/passwords",
"path": "/src/generators/case.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: b-r-oleary/passwords path: /src/generators/case.rs
use inflector::Inflector;
use rand::rngs::ThreadRng;
use super::base::PasswordGenerator;
/// A password generator object that will modify the case of a seed password string.
///
/// This is a loose wrapper around functions provided by the `inf... | code_fim | hard | {
"lang": "rust",
"repo": "b-r-oleary/passwords",
"path": "/src/generators/case.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Patryk27/janet path: /libs/interface/src/command/merge_request/parse.rs
use crate::{Atom, CommandAction, DateTime, MergeRequestCommand, MergeRequestPtr};
use nom::branch::alt;
use nom::bytes::complete::{tag, tag_no_case, take_while};
use nom::combinator::{all_consuming, opt, rest};
use nom::{IRe... | code_fim | hard | {
"lang": "rust",
"repo": "Patryk27/janet",
"path": "/libs/interface/src/command/merge_request/parse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mod manage_reminder {
use super::*;
use test_case::test_case;
#[test_case("remind tomorrow at 12: important important!" ; "without me")]
#[test_case("remind me tomorrow at 12: important important!" ; "with me")]
fn with_message(input: &str) {
assert... | code_fim | hard | {
"lang": "rust",
"repo": "Patryk27/janet",
"path": "/libs/interface/src/command/merge_request/parse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: microsoft/DiskANN path: /rust/vector/src/utils.rs
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*/
use std::arch::x86_64::{_mm_prefetch, _MM_HINT_T0};
<|fim_suffix|> for d in (0..max_prefetch_size).step_by(64) {
unsafe {
... | code_fim | hard | {
"lang": "rust",
"repo": "microsoft/DiskANN",
"path": "/rust/vector/src/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for d in (0..max_prefetch_size).step_by(64) {
unsafe {
_mm_prefetch(vec_ptr.add(d), _MM_HINT_T0);
}
}
}<|fim_prefix|>// repo: microsoft/DiskANN path: /rust/vector/src/utils.rs
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT lic... | code_fim | hard | {
"lang": "rust",
"repo": "microsoft/DiskANN",
"path": "/rust/vector/src/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oOBoomberOo/fusion path: /tests/criteria.rs
use superfusion::criteria::Composite;
fn create_composite() -> Composite {
Composite::new()
.with(|path| path.join("pack.mcmeta").is_file())
.with(|path| path.join("data").is_dir())
.with(|path| {
path.join("data/minecraft/tags/functions/tic... | code_fim | hard | {
"lang": "rust",
"repo": "oOBoomberOo/fusion",
"path": "/tests/criteria.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn non_existing_dir() {
let composite = create_composite();
let should_fail = !composite.check("tests/criteria/non_existing_dir");
assert!(should_fail)
}<|fim_prefix|>// repo: oOBoomberOo/fusion path: /tests/criteria.rs
use superfusion::criteria::Composite;
fn create_composite() -> Composite ... | code_fim | hard | {
"lang": "rust",
"repo": "oOBoomberOo/fusion",
"path": "/tests/criteria.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Drop for PrepareFetch {
fn drop(&mut self) {
if let Some(repo) = self.repo.take() {
std::fs::remove_dir_all(repo.work_dir().unwrap_or_else(|| repo.path())).ok();
}
}
}
impl From<PrepareFetch> for Repository {
fn from(prep: PrepareFetch) -> Self {
prep.... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix/src/clone/access.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/gitoxide path: /gix/src/clone/access.rs
use crate::{bstr::BString, clone::PrepareFetch, Repository};
/// Builder
impl PrepareFetch {
/// Use `f` to apply arbitrary changes to the remote that is about to be used to fetch a pack.
///
/// The passed in `remote` will be un-named a... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix/src/clone/access.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let b_main = gtk::Box::new(gtk::Orientation::Vertical, 0);
let l_main = gtk::Label::new(Some("Pimple"));
let b_calendar = gtk::Box::new(gtk::Orientation::Horizontal, 0);
for day in 0..7 {
let b_day = gtk::Box::new(gtk::Orientation::Vertical, 0);
let ... | code_fim | medium | {
"lang": "rust",
"repo": "ryzokuken/pimple",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryzokuken/pimple path: /src/main.rs
extern crate time;
extern crate gtk;
extern crate gio;
use gtk::prelude::*;
use gio::prelude::*;
fn main() {
let application = gtk::Application::new(
Some("dev.ryzokuken.pimple"),
Default::default(),
).expect("failed to initialize gtk... | code_fim | medium | {
"lang": "rust",
"repo": "ryzokuken/pimple",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daneb/engineering_algorithms path: /src/mergesort/merge_sort.rs
fn merge_sort(array_to_sort : &mut [i32]) -> (Vec<i32>, i64) {
if array_to_sort.len() == 1 { return (array_to_sort.to_vec(), 0) };
let (left, right) = array_to_sort.split_at_mut(array_to_sort.len() / 2);
let (part... | code_fim | hard | {
"lang": "rust",
"repo": "daneb/engineering_algorithms",
"path": "/src/mergesort/merge_sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while left_idx < left.len() && right_idx < right.len()
{
if left[left_idx] <= right[right_idx] {
v.push(left[left_idx]);
left_idx += 1;
} else {
v.push(right[right_idx]);
right_idx += 1;
// The distance of the swap
... | code_fim | hard | {
"lang": "rust",
"repo": "daneb/engineering_algorithms",
"path": "/src/mergesort/merge_sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mdraeger/networks path: /src/alg_runner.rs
use std::collections::HashMap;
use network::{ DoubleVec, Network, NodeId };
use network::algorithms::{ dijkstra, pagerank };
use usage::{ DEFAULT_BETA, DEFAULT_EPS, DEFAULT_START_ID, Args };
#[derive(Debug, RustcDecodable)]
pub enum Algorithm { dijkst... | code_fim | hard | {
"lang": "rust",
"repo": "mdraeger/networks",
"path": "/src/alg_runner.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match target_node {
None => println!("No target node given."),
Some(name) => {
let id = node_to_id[name] as usize;
println!("Rank of node {}: {} ({:e})", name, ranks[id], ranks[id]);
}
}
}<|fim_prefix|>// repo: mdraeger/networks path: /src/alg_runne... | code_fim | medium | {
"lang": "rust",
"repo": "mdraeger/networks",
"path": "/src/alg_runner.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>static TDISPATCH_BUF: &'static [u8] = &[
0, 0, 0, 0, 0, 0, 0, 65, // frame size
2, // type: TDISPATCH
0, 1, 2, // tag
// contexts:
0, 2, // 2 contexts
// context 0 key
0, 4, // length
1, 2, 3, 4,
// context 0 val
0, 2, // length
6, 7,
// context 1 key
... | code_fim | medium | {
"lang": "rust",
"repo": "stevej/mux-rust",
"path": "/benches/tdispatch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stevej/mux-rust path: /benches/tdispatch.rs
extern crate test;
extern crate mux;
use mux::misc::{Context, Dentry, Dtab};
use mux::proto::{Tag, Msg, MsgType};
use mux::reader::MuxReader;
use mux::writer::MuxWriter;
use std::io::{BufReader, MemWriter};
use test::Bencher;
#[inline]
fn read(buf: &... | code_fim | medium | {
"lang": "rust",
"repo": "stevej/mux-rust",
"path": "/benches/tdispatch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let msg = Msg::Tdispatch(
vec![Context::new(vec![1,2,3,4], vec![6,7]),
Context::new(vec![3,4], vec![6,7,8])],
"/BAD".to_string(),
Dtab(vec![Dentry::new("/BAD".to_string(), "/DAD".to_string())]),
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,... | code_fim | medium | {
"lang": "rust",
"repo": "stevej/mux-rust",
"path": "/benches/tdispatch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (res, record) = super::simple_record("A(1, 2.0)").finish().unwrap();
dbg!(record);
assert_eq!(res, "");
}
#[test]
fn simple_recode2() {
let (res, record) = super::simple_record(
"LENGTH_MEASURE_WITH_UNIT( LENGTH_MEASURE( 1.00000000000000 ), #359... | code_fim | hard | {
"lang": "rust",
"repo": "zeta1999/ruststep",
"path": "/ruststep/src/parser/exchange/data.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zeta1999/ruststep path: /ruststep/src/parser/exchange/data.rs
use crate::{
parser::{combinator::*, exchange::*, token::*},
step::*,
};
use nom::{branch::alt, Parser};
#[derive(Debug, Clone, PartialEq)]
pub struct DataSection {
pub meta: Vec<Parameter>,
pub entities: Vec<EntityIn... | code_fim | hard | {
"lang": "rust",
"repo": "zeta1999/ruststep",
"path": "/ruststep/src/parser/exchange/data.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// subsuper_record = `(` [simple_record_list] `)` .
pub fn subsuper_record(input: &str) -> ParseResult<Vec<Record>> {
tuple_((char_('('), simple_record_list, char_(')')))
.map(|(_open, records, _close)| records)
.parse(input)
}
#[cfg(test)]
mod tests {
use nom::Finish;
#[tes... | code_fim | hard | {
"lang": "rust",
"repo": "zeta1999/ruststep",
"path": "/ruststep/src/parser/exchange/data.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebookexperimental/rust-shed path: /shed/quickcheck_arbitrary_derive/examples/example.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apa... | code_fim | hard | {
"lang": "rust",
"repo": "facebookexperimental/rust-shed",
"path": "/shed/quickcheck_arbitrary_derive/examples/example.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Arbitrary, Clone, Debug)]
struct TupleFoo(u8, String);
#[derive(Arbitrary, Clone, Debug)]
enum EnumFoo {
Foo { foo: StructFoo, bar: Vec<u8> },
Bar { hello: i64 },
Baz(u8),
Qux,
}
fn main() {
use quickcheck::Arbitrary;
use quickcheck::Gen;
let mut gen = Gen::new(10);
... | code_fim | medium | {
"lang": "rust",
"repo": "facebookexperimental/rust-shed",
"path": "/shed/quickcheck_arbitrary_derive/examples/example.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>AY`"]
#[inline(always)]
pub fn is_emcclk_plus_one_delay(&self) -> bool {
*self == RD_A::EMCCLK_PLUS_ONE_DELAY
}
#[doc = "Checks if the value of the field is `EMCCLK_PLUS_TWO_DELAY`"]
#[inline(always)]
pub fn is_emcclk_plus_two_delay(&self) -> bool {
*self == RD_A::E... | code_fim | hard | {
"lang": "rust",
"repo": "fuchsch1234/lpc178x_7x",
"path": "/src/emc/dynamicreadconfig.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fuchsch1234/lpc178x_7x path: /src/emc/dynamicreadconfig.rs
#[doc = "Reader of register DYNAMICREADCONFIG"]
pub type R = crate::R<u32, super::DYNAMICREADCONFIG>;
#[doc = "Writer for register DYNAMICREADCONFIG"]
pub type W = crate::W<u32, super::DYNAMICREADCONFIG>;
#[doc = "Register DYNAMICREADCON... | code_fim | hard | {
"lang": "rust",
"repo": "fuchsch1234/lpc178x_7x",
"path": "/src/emc/dynamicreadconfig.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>RD_A::EMCCLK_DELAY)
}
#[doc = "Command delayed strategy plus one clock cycle, using EMCCLKDELAY (command delayed, clock out not delayed)."]
#[inline(always)]
pub fn emcclk_plus_one_delay(self) -> &'a mut W {
self.variant(RD_A::EMCCLK_PLUS_ONE_DELAY)
}
#[doc = "Command delay... | code_fim | hard | {
"lang": "rust",
"repo": "fuchsch1234/lpc178x_7x",
"path": "/src/emc/dynamicreadconfig.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aphelionz/ambients path: /crates/parser/src/lib.rs
#![deny(warnings)]
mod ast;
#[macro_use] extern crate lalrpop_util;
lalrpop_mod!(pub ambients); // synthesized by LALRPOP
#[cfg(test)]
mod test {
use pretty_assertions::{ assert_eq };
use super::ambients::{ ExecutionParser as Parser }... | code_fim | hard | {
"lang": "rust",
"repo": "aphelionz/ambients",
"path": "/crates/parser/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let program = "
x[call[out x.in y.open_|payload[]] | out_ call] |
y[in_ call.open call]
";
let expr = Parser::new().parse(program).unwrap();
let expected = Parallel(vec![
Ambient("x", Box::new(Parallel(vec![
Ambient("call", Box::new(Parallel(vec![
... | code_fim | hard | {
"lang": "rust",
"repo": "aphelionz/ambients",
"path": "/crates/parser/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>where
S::Error: ParseError<char, S::Range, S::Position>,
{
parser(parse_primitive)
.map(JavaType::Primitive)
.or(parser(parse_array))
.or(parser(parse_object))
.or(parser(parse_sig))
.parse_stream(input)
.into()
}
fn parse_return<S: Stream<Token = c... | code_fim | hard | {
"lang": "rust",
"repo": "jni-rs/jni-rs",
"path": "/src/wrapper/signature.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jni-rs/jni-rs path: /src/wrapper/signature.rs
use std::{fmt, str::FromStr};
use combine::{
between, many, many1, parser, satisfy, token, ParseError, Parser, StdParseResult, Stream,
};
use crate::errors::*;
/// A primitive java type. These are the things that can be represented without
///... | code_fim | hard | {
"lang": "rust",
"repo": "jni-rs/jni-rs",
"path": "/src/wrapper/signature.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> obj.map(JavaType::Object).parse_stream(input).into()
}
fn parse_type<S: Stream<Token = char>>(input: &mut S) -> StdParseResult<JavaType, S>
where
S::Error: ParseError<char, S::Range, S::Position>,
{
parser(parse_primitive)
.map(JavaType::Primitive)
.or(parser(parse_array))
... | code_fim | hard | {
"lang": "rust",
"repo": "jni-rs/jni-rs",
"path": "/src/wrapper/signature.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let u = m::U { a: 0 }; // OK
let u = m::U { b: 0 }; // OK
let u = m::U { c: 0 }; //~ ERROR field `c` of union `m::U` is private
let m::U { a } = u; // OK
let m::U { b } = u; // OK
let m::U { c } = u; //~ ERROR field `c` of union `m::U` is private
}}<|fim_prefix|>// repo: IThawk/ru... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/privacy/union-field-privacy-1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/privacy/union-field-privacy-1.rs
mod m {
pub union U {
pub a: u8,
pub(super) b: u8,
c: u8,
}
}
fn main() { unsafe {
<|fim_suffix|> let m::U { a } = u; // OK
let m::U { b } = u; // OK
let m::U { c } = u... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/privacy/union-field-privacy-1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match cmd {
commands::Command::Led(on) => {
let onoff = if on { "on" } else { "off" };
let msg = format!("led {}\n", onoff);
port.write(msg.as_bytes())
},
commands::Command::Servo(id, angle) => {
le... | code_fim | hard | {
"lang": "rust",
"repo": "wade-welles/roboarm",
"path": "/teleop/src/serial/comms.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wade-welles/roboarm path: /teleop/src/serial/comms.rs
pub mod comms {
use commands;
use serialport;
use std::io;
use std::sync::mpsc;
/// Communicate with the device by listening on a channel from the console
/// thread and sending the received commands over UART.
//... | code_fim | hard | {
"lang": "rust",
"repo": "wade-welles/roboarm",
"path": "/teleop/src/serial/comms.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Attempts to write the command to the port. Returns whether or not it worked.
fn write_to_port(port: &mut Box<serialport::SerialPort>, cmd: commands::Command) -> io::Result<usize> {
match cmd {
commands::Command::Led(on) => {
let onoff = if on { "on" } else {... | code_fim | hard | {
"lang": "rust",
"repo": "wade-welles/roboarm",
"path": "/teleop/src/serial/comms.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Copy)]
enum OutputConfig {
Mono = 1,
Stereo = 2,
}
impl From<u16> for OutputConfig {
fn from(value: u16) -> Self {
use OutputConfig::*;
match value {
1 => Mono,
2 => Stereo,
_ => panic!("Only Mono and Stereo audio devices sup... | code_fim | hard | {
"lang": "rust",
"repo": "siraben/NDS-Emulator",
"path": "/core/src/hw/spu/audio.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: siraben/NDS-Emulator path: /core/src/hw/spu/audio.rs
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use ringbuf::RingBuffer;
pub struct Audio {
config: cpal::StreamConfig,
_stream: cpal::Stream,
prod: ringbuf::Producer<[f32; 2]>,
}
impl Audio {
const BUFFER_LEN: usize... | code_fim | hard | {
"lang": "rust",
"repo": "siraben/NDS-Emulator",
"path": "/core/src/hw/spu/audio.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Audio {
config,
_stream: stream,
prod,
}
}
pub fn push_sample(&mut self, left_sample: f32, right_sample: f32) {
while self.prod.is_full() {} // TODO: Block thread instead of using CPU
self.prod.push([left_sample, right_sample]).u... | code_fim | hard | {
"lang": "rust",
"repo": "siraben/NDS-Emulator",
"path": "/core/src/hw/spu/audio.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jblindsay/whitebox-tools path: /whitebox-tools-app/src/tools/data_tools/print_geotiff_tags.rs
/*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: March 2, 2018
Last Modified: March 2, 2018
License: MIT
*/
use whitebox_raster::geotiff::*;
use... | code_fim | hard | {
"lang": "rust",
"repo": "jblindsay/whitebox-tools",
"path": "/whitebox-tools-app/src/tools/data_tools/print_geotiff_tags.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sep: String = path::MAIN_SEPARATOR.to_string();
if !input_file.contains(&sep) && !input_file.contains("/") {
input_file = format!("{}{}", working_directory, input_file);
}
// make sure that it is a tiff file
if !input_file.to_lowercase().ends_with(... | code_fim | hard | {
"lang": "rust",
"repo": "jblindsay/whitebox-tools",
"path": "/whitebox-tools-app/src/tools/data_tools/print_geotiff_tags.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>he HWT tracer.
println!("cargo:rustc-cfg=tracer_hwt");
}<|fim_prefix|>// repo: ltratt/yk path: /ykrt/build.rs
pub fn main() {
ykbuild::apply_llvm_ld_library_path();
// Always compile in the LLVM JIT compiler.
printl<|fim_middle|>n!("cargo:rustc-cfg=jitc_llvm");
// Always compile in t | code_fim | easy | {
"lang": "rust",
"repo": "ltratt/yk",
"path": "/ykrt/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ltratt/yk path: /ykrt/build.rs
pub fn main() {
ykbuild::apply_llvm_ld_library_path();
<|fim_suffix|>n!("cargo:rustc-cfg=jitc_llvm");
// Always compile in the HWT tracer.
println!("cargo:rustc-cfg=tracer_hwt");
}<|fim_middle|>
// Always compile in the LLVM JIT compiler.
printl | code_fim | easy | {
"lang": "rust",
"repo": "ltratt/yk",
"path": "/ykrt/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> trace!("write(0x{:04X}, 0x{:02X})", addr, val);
match addr {
// 32KB cartridge write
0x0000..=0x7FFF => self.cart.write(addr, val),
// 8KB Video RAM (VRAM) (switchable bank 0-1 in CGB Mode)
0x8000..=0x9FFF => {
let i = (addr... | code_fim | hard | {
"lang": "rust",
"repo": "wez470/Rugby",
"path": "/src/cpu/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The `Inst::And` instruction.
fn and_accum(&mut self, n: Operand8) {
self.regs.a &= self.get_operand_8(n);
self.set_flag(Flag::Zero, self.regs.a == 0);
self.set_flag(Flag::Sub, false);
self.set_flag(Flag::HalfCarry, true);
self.set_flag(Flag::Carry, false... | code_fim | hard | {
"lang": "rust",
"repo": "wez470/Rugby",
"path": "/src/cpu/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wez470/Rugby path: /src/cpu/mod.rs
(old_val, 1));
}
/// The 16-bit `Inst::Inc` instruction.
fn inc_16(&mut self, n: Operand16) {
let val = self.get_operand_16(n).wrapping_add(1);
self.set_operand_16(n, val);
}
/// The 16-bit `Inst::Dec` instruction.
fn d... | code_fim | hard | {
"lang": "rust",
"repo": "wez470/Rugby",
"path": "/src/cpu/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crossterm-rs/terminal path: /src/enums/terminal.rs
/// Different ways to clear the terminal buffer.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub enum Clear {
/// All cells.
All,
/// All cells fr... | code_fim | medium | {
"lang": "rust",
"repo": "crossterm-rs/terminal",
"path": "/src/enums/terminal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>cursor position downwards.
FromCursorDown,
/// All cells from the cursor position upwards.
FromCursorUp,
/// All cells at the cursor row.
CurrentLine,
/// All cells from the cursor position until the new line.
UntilNewLine,
}<|fim_prefix|>// repo: crossterm-rs/terminal path: /... | code_fim | medium | {
"lang": "rust",
"repo": "crossterm-rs/terminal",
"path": "/src/enums/terminal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Faction membership.
#[derive(Clone, Copy, Debug)]
pub struct Standing {
/// The faction.
pub faction: Faction,
/// The entity's standing with the faction.
pub standing: i32,
/// Any penalties the entity might be under with the faction.
pub penalty: Option<Penalty>,
}<|fim_prefi... | code_fim | hard | {
"lang": "rust",
"repo": "ndouglas/azymus",
"path": "/src/faction/mod.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ndouglas/azymus path: /src/faction/mod.rs
use crate::species;
use species::Species;
/// Faction class.
#[derive(Clone, Copy, Debug)]
pub enum Faction {
/// The player faction.
Player,
/// A species-based faction.
Species(Species),
}
<|fim_suffix|>/// Penalties/Rewards given by ... | code_fim | hard | {
"lang": "rust",
"repo": "ndouglas/azymus",
"path": "/src/faction/mod.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustic-games/vienna path: /crates/common/src/canvas.rs
//! Details about the canvas within which the game is rendered.
use crate::{Deserialize, Serialize};
/// Canvas details.
#[derive(Debug, Default, Copy, Clone, Serialize, Deserialize)]
pub struct Canvas {
/// The width of the canvas.
... | code_fim | medium | {
"lang": "rust",
"repo": "rustic-games/vienna",
"path": "/crates/common/src/canvas.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the dimensions (width, height) of the canvas.
#[inline]
#[must_use]
pub const fn dimensions(self) -> (u16, u16) {
(self.width, self.height)
}
}<|fim_prefix|>// repo: rustic-games/vienna path: /crates/common/src/canvas.rs
//! Details about the canvas within which the ga... | code_fim | hard | {
"lang": "rust",
"repo": "rustic-games/vienna",
"path": "/crates/common/src/canvas.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ilya-epifanov/heim path: /heim-disk/src/sys/windows/bindings/perf.rs
use std::io;
use std::mem;
use std::os::windows::ffi::OsStrExt;
use std::path::Path;
use std::ptr;
use winapi::shared::{minwindef, winerror};
use winapi::um::{fileapi, handleapi, ioapiset, winioctl, winnt};
use heim_common::p... | code_fim | medium | {
"lang": "rust",
"repo": "ilya-epifanov/heim",
"path": "/heim-disk/src/sys/windows/bindings/perf.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = unsafe {
ioapiset::DeviceIoControl(
handle,
winioctl::IOCTL_DISK_PERFORMANCE,
ptr::null_mut(),
0,
&mut perf as *mut _ as minwindef::LPVOID,
mem::size_of::<winioctl::DISK_PERFORMANCE>() as minwindef::DWORD,
... | code_fim | medium | {
"lang": "rust",
"repo": "ilya-epifanov/heim",
"path": "/heim-disk/src/sys/windows/bindings/perf.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> if entry.c.contains(char_pos_1) {
match_counter += 1;
}
if entry.c.contains(char_pos_2) {
match_counter += 1;
}
// Statement without semicolon on the last line
// is the same as 'return match_counter == 1;'
match_counter == 1
}
pub fn solve_day2(filename: &St... | code_fim | hard | {
"lang": "rust",
"repo": "jimmykarls/adventofcode2020",
"path": "/rust/src/day2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* & => borrow. Without it the for loop will cause a move */
for entry in &entries {
if is_entry_valid(&entry) {
n_valid_entries += 1;
}
}
println!("Number of valid entries are {}/{}", n_valid_entries, len);
/* Problem 2 */
/* Three ways of calculating ... | code_fim | hard | {
"lang": "rust",
"repo": "jimmykarls/adventofcode2020",
"path": "/rust/src/day2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jimmykarls/adventofcode2020 path: /rust/src/day2.rs
use std::fs::File;
use std::io::Read;
use regex::Regex;
use std::convert::TryFrom;
// #[derive(Copy, Clone)]
struct Entry {
min_times: i32,
max_times: i32,
password: String,
c: String,
}
fn parse_file(filename: &String, out:... | code_fim | hard | {
"lang": "rust",
"repo": "jimmykarls/adventofcode2020",
"path": "/rust/src/day2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn need_healing(&self, game: &Game) -> bool {
return (self.health as f32 / game.properties.unit_max_health as f32) <= 0.8;
}
}<|fim_prefix|>// repo: stulentsev/russianaicup path: /CodeSide/model/src/unit.rs
use crate::*;
#[derive(Copy, Clone, Debug, trans::Trans)]
pub struct Unit {
... | code_fim | hard | {
"lang": "rust",
"repo": "stulentsev/russianaicup",
"path": "/CodeSide/model/src/unit.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn has_weapon(&self) -> bool {
self.weapon.is_some()
}
pub fn bounding_box(&self) -> BoundingBox {
BoundingBox {
bottom_left: self.position.add_x(-self.size.x / 2.0),
size: self.size.clone(),
}
}
pub fn need_healing(&self, game: &Ga... | code_fim | medium | {
"lang": "rust",
"repo": "stulentsev/russianaicup",
"path": "/CodeSide/model/src/unit.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stulentsev/russianaicup path: /CodeSide/model/src/unit.rs
use crate::*;
#[derive(Copy, Clone, Debug, trans::Trans)]
pub struct Unit {
pub player_id: i32,
pub id: i32,
pub health: i32,
pub position: Vec2F64,
pub size: Vec2F64,
pub jump_state: JumpState,
pub walked_righ... | code_fim | hard | {
"lang": "rust",
"repo": "stulentsev/russianaicup",
"path": "/CodeSide/model/src/unit.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: INDAPlus21/azeezd-chess path: /src/chess/piece_data.rs
/// Pieces used in chess
#[derive(PartialEq, Debug, Copy, Clone)]
pub en<|fim_suffix|>(PartialEq, Debug, Copy, Clone)]
pub enum Colour {
White,
Black
}<|fim_middle|>um PieceType {
None,
Pawn,
Knight,
Bishop,
Rook,... | code_fim | medium | {
"lang": "rust",
"repo": "INDAPlus21/azeezd-chess",
"path": "/src/chess/piece_data.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>(PartialEq, Debug, Copy, Clone)]
pub enum Colour {
White,
Black
}<|fim_prefix|>// repo: INDAPlus21/azeezd-chess path: /src/chess/piece_data.rs
/// Pieces used in chess
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum PieceType {
None,
Pawn,
Knight,
Bishop,
Rook,
<|fim_mid... | code_fim | medium | {
"lang": "rust",
"repo": "INDAPlus21/azeezd-chess",
"path": "/src/chess/piece_data.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_insert_from_path()
{
// Prepare the test.
let test_data = TestData::new("test_insert_from_path").unwrap();
let volume = Volume::open(test_data.volume1_path).unwrap();
// Insert the objects.
let hash1 = volume.insert_from_path(&test_data.... | code_fim | hard | {
"lang": "rust",
"repo": "chloekek/wallace",
"path": "/wallace_volume/src/volume.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chloekek/wallace path: /wallace_volume/src/volume.rs
use crate::Hash;
use crate::InvalidHash;
use std::fs::File;
use std::fs::OpenOptions;
use std::fs::Permissions;
use std::fs::create_dir;
use std::io::Error;
use std::io::ErrorKind::AlreadyExists;
use std::io::ErrorKind::NotFound;
use std::io::... | code_fim | hard | {
"lang": "rust",
"repo": "chloekek/wallace",
"path": "/wallace_volume/src/volume.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ShuoWangNSL/prism-rust path: /src/block/header.rs
use crate::crypto::hash::{Hashable, H256};
// TODO: Add the address of the miner
/// The header of a block.
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Copy)]
pub struct Header {
/// Hash of the parent proposer block.
pub parent... | code_fim | hard | {
"lang": "rust",
"repo": "ShuoWangNSL/prism-rust",
"path": "/src/block/header.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ///The hash should match
#[test]
fn test_hash() {
let header = sample_header();
let header_hash_should_be = sample_header_hash_should_be();
assert_eq!(header.hash(), header_hash_should_be);
}
#[macro_export]
macro_rules! gen_hashed_data {
() => {{
... | code_fim | hard | {
"lang": "rust",
"repo": "ShuoWangNSL/prism-rust",
"path": "/src/block/header.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: F3kilo/infrastructure_prototype path: /src/model/error/update.rs
use super::model_not_free::ModelNotFreeError;
use std::error::Error;
use std::fmt;
use std::sync::mpsc::SendError;
#[derive(Debug)]
pub enum UpdateError {
ModelNotFree(ModelNotFreeError),
CantSendToPresenter,
}
impl Error... | code_fim | hard | {
"lang": "rust",
"repo": "F3kilo/infrastructure_prototype",
"path": "/src/model/error/update.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<M> From<SendError<M>> for UpdateError {
fn from(_: SendError<M>) -> Self {
UpdateError::CantSendToPresenter
}
}
impl From<ModelNotFreeError> for UpdateError {
fn from(e: ModelNotFreeError) -> Self {
UpdateError::ModelNotFree(e)
}
}<|fim_prefix|>// repo: F3kilo/infrast... | code_fim | hard | {
"lang": "rust",
"repo": "F3kilo/infrastructure_prototype",
"path": "/src/model/error/update.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: timbod7/fsim-pedals path: /software/fs-pedals/src/main.rs
//! CDC-ACM serial port example using interrupts.
#![no_std]
#![no_main]
extern crate panic_semihosting;
use cortex_m::asm::{delay};
use cortex_m_rt::entry;
use cortex_m::interrupt::free as disable_interrupts;
use cortex_m::peripheral::... | code_fim | hard | {
"lang": "rust",
"repo": "timbod7/fsim-pedals",
"path": "/software/fs-pedals/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Unsafe to allow access to static variables
unsafe {
let bus = UsbBus::new(usb);
USB_BUS = Some(bus);
USB_HID = Some(HIDClass::new(USB_BUS.as_ref().unwrap(), JoystickReport::desc(), 60));
let usb_dev = UsbDeviceBuilder::new(USB_BUS.as_ref().unwrap(), UsbVidPid(... | code_fim | hard | {
"lang": "rust",
"repo": "timbod7/fsim-pedals",
"path": "/software/fs-pedals/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, PartialEq, Clone, Copy)]
pub enum ObjectType {
Star, Bullet(usize, f64), Ship(usize), BlackHole, Mothership
}<|fim_prefix|>// repo: Tehforsch/amazingGrame path: /src/game/object.rs
#[derive(Clone, Copy, Debug)]
pub struct Object {
pub body: usize,
pub type_: ObjectType,
pu... | code_fim | medium | {
"lang": "rust",
"repo": "Tehforsch/amazingGrame",
"path": "/src/game/object.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tehforsch/amazingGrame path: /src/game/object.rs
#[derive(Clone, Copy, Debug)]
pub struct Object {
pub body: usize,
pub type_: ObjectType,
pub should_be_removed: bool
}
<|fim_suffix|>#[derive(Debug, PartialEq, Clone, Copy)]
pub enum ObjectType {
Star, Bullet(usize, f64), Ship(us... | code_fim | medium | {
"lang": "rust",
"repo": "Tehforsch/amazingGrame",
"path": "/src/game/object.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/style-servo/components/script/dom/closeevent.rs
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/style-servo/components/script/dom/closeevent.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl CloseEventMethods for CloseEvent {
// https://html.spec.whatwg.org/multipage/#dom-closeevent-wasclean
fn WasClean(&self) -> bool {
self.was_clean
}
// https://html.spec.whatwg.org/multipage/#dom-closeevent-code
fn Code(&self) -> u16 {
self.code
}
// https... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/style-servo/components/script/dom/closeevent.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dignifiedquire/azul path: /azul-widgets/src/lib.rs
#[cfg(feature = "serde_serialization")]
#[cfg_attr(feature = "serde_serialization", macro_use(Serialize, Deserialize))]
extern crate serde_derive;
<|fim_suffix|>pub mod errors {
#[cfg(all(feature = "svg", feature = "svg_parsing"))]
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "dignifiedquire/azul",
"path": "/azul-widgets/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod errors {
#[cfg(all(feature = "svg", feature = "svg_parsing"))]
pub use super::svg::SvgParseError;
}<|fim_prefix|>// repo: dignifiedquire/azul path: /azul-widgets/src/lib.rs
#[cfg(feature = "serde_serialization")]
#[cfg_attr(feature = "serde_serialization", macro_use(Serialize, Deserialize... | code_fim | medium | {
"lang": "rust",
"repo": "dignifiedquire/azul",
"path": "/azul-widgets/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let total_count = count_query
.count()
.get_result(&*conn)
.map_err(|err| ApiError::InternalError(err.to_string()))?;
let paging_info = apply_paging(link_params, head_block_num, total_count)?;
factories_query = factories_query.limit(params.limit.unwrap_or(DEFAULT_LIMIT... | code_fim | hard | {
"lang": "rust",
"repo": "adeebahmed/consensource-api",
"path": "/src/route_handlers/factories.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adeebahmed/consensource-api path: /src/route_handlers/factories.rs
use std::collections::HashMap;
use database::DbConn;
use database_manager::custom_types::OrganizationTypeEnum;
use database_manager::models::{
Address, Authorization, Certificate, Contact, Organization, Standard,
};
use data... | code_fim | hard | {
"lang": "rust",
"repo": "adeebahmed/consensource-api",
"path": "/src/route_handlers/factories.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn query_certifications(
conn: DbConn,
head_block_num: i64,
factory_ids: &[String],
) -> Result<Vec<(Certificate, Standard, Organization)>, ApiError> {
certificates::table
.filter(certificates::start_block_num.le(head_block_num))
.filter(certificates::end_block_num.gt(head_... | code_fim | hard | {
"lang": "rust",
"repo": "adeebahmed/consensource-api",
"path": "/src/route_handlers/factories.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Muirrum/rust-text-adventure path: /src/lib.rs
pub mod commands;
mod spatial;
use crate::commands::CommandRepo;
use crate::spatial::locations::{Location, Point};
use std::io;
pub struct Player {
pub name: String,
pub hp: i32,
pub location: Location,
}
pub struct World {
pub loca... | code_fim | hard | {
"lang": "rust",
"repo": "Muirrum/rust-text-adventure",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> locations
}
pub fn get_input() -> String {
let mut answer = String::new();
io::stdin()
.read_line(&mut answer)
.expect("Could not read line");
answer
}<|fim_prefix|>// repo: Muirrum/rust-text-adventure path: /src/lib.rs
pub mod commands;
mod spatial;
use crate::commands:... | code_fim | hard | {
"lang": "rust",
"repo": "Muirrum/rust-text-adventure",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod part1_tests {
use super::*;
#[test]
fn part_1() {
let input = "light red bags contain 1 bright white bag, 2 muted yellow bags.\ndark orange bags contain 3 bright white bags, 4 muted yellow bags.\nbright white bags contain 1 shiny gold bag.\nmuted yellow bags contain 2 ... | code_fim | hard | {
"lang": "rust",
"repo": "cgrimes01/adventofcode",
"path": "/2020/day7/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cgrimes01/adventofcode path: /2020/day7/src/main.rs
use std::fs;
use std::collections::HashMap;
fn main() {
let input = fs::read_to_string("input.txt").unwrap();
println!("Part 1 = {}", part1(&input, "shiny gold".to_string()));
println!("Part 2 = {}", part2(&input, "shiny gold".to_s... | code_fim | hard | {
"lang": "rust",
"repo": "cgrimes01/adventofcode",
"path": "/2020/day7/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut containingbags : HashMap<String, String> = HashMap::new();
for bag in bags {
match bag.contents.get(&colour) {
Some(_) => {
containingbags.insert(bag.colour.clone(), bag.colour.clone());
let result = get_bags_containing(bag.colour.clone(... | code_fim | hard | {
"lang": "rust",
"repo": "cgrimes01/adventofcode",
"path": "/2020/day7/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn PerformanceAPI_EndEvent() -> PerformanceAPI_SuppressTailCallOptimization;
}<|fim_prefix|>// repo: isgasho/superluminal-perf-rs path: /sys/src/lib.rs
use std::os::raw::c_char;
pub const DEFAULT_COLOR: u32 = 0xFF_FF_FF_FF;
#[repr(C)]
pub struct PerformanceAPI_SuppressTailCallOptimization {
... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/superluminal-perf-rs",
"path": "/sys/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/superluminal-perf-rs path: /sys/src/lib.rs
use std::os::raw::c_char;
pub const DEFAULT_COLOR: u32 = 0xFF_FF_FF_FF;
#[repr(C)]
pub struct PerformanceAPI_SuppressTailCallOptimization {
_private: [u64; 3],
}
extern "C" {
pub fn PerformanceAPI_SetCurrentThreadName(in_thread_name: ... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/superluminal-perf-rs",
"path": "/sys/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VenmoTools/OperatingSystem path: /kernel/system/src/ia_32e/paging/frame.rs
use core::fmt;
use core::marker::PhantomData;
use core::ops::{Add, AddAssign, Sub, SubAssign};
use crate::ia_32e::PhysAddr;
use crate::result::{Error, Result};
use crate::result::error::mem::MemErrorKind;
use super::pag... | code_fim | hard | {
"lang": "rust",
"repo": "VenmoTools/OperatingSystem",
"path": "/kernel/system/src/ia_32e/paging/frame.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// 物理内存范围
#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(C)]
pub struct FrameRange<S: PageSize = Page4KB> {
/// 起始.
pub start: Frame<S>,
/// 终止不包含.
pub end: Frame<S>,
}
impl<S: PageSize> FrameRange<S> {
pub fn is_empty(&self) -> bool {
!(self.start < self.end)
}
}
impl<S: ... | code_fim | hard | {
"lang": "rust",
"repo": "VenmoTools/OperatingSystem",
"path": "/kernel/system/src/ia_32e/paging/frame.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<S: PageSize> fmt::Debug for FrameRange<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("FrameRange")
.field("start", &self.start)
.field("end", &self.end)
.finish()
}
}
impl<S: PageSize> fmt::Debug for Frame<S> {
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "VenmoTools/OperatingSystem",
"path": "/kernel/system/src/ia_32e/paging/frame.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DariuszO/tonos-se path: /ton-node-se/ton_node/src/error.rs
extern crate ethcore_network as network;
// use poa::error::PoaError;
use std::io;
// use tvm::types::Exception;
error_chain! {
types {
NodeError, NodeErrorKind, NodeResultExt, NodeResult;
}
foreign_links {
... | code_fim | hard | {
"lang": "rust",
"repo": "DariuszO/tonos-se",
"path": "/ton-node-se/ton_node/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// foreign_links {
// Adnl(AdnlError) #[doc = "Adnl error"];
// Node(NodeError) #[doc = "Node error"];
// Poa(PoaError) #[doc = "PoA error"];
// Tvm(Exception) #[doc = "TVM exception"];
// Block(BlockError) #[doc = "TonBlock error"];
// }
// }
// impl From... | code_fim | hard | {
"lang": "rust",
"repo": "DariuszO/tonos-se",
"path": "/ton-node-se/ton_node/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BugenZhao/6.824-MapReduce path: /app-early-exit/src/lib.rs
use std::sync::atomic::AtomicUsize;
use std::thread;
use std::time::Duration;
use common::declare_app;
use common::App;
#[derive(Debug, Default)]
struct IndexerApp {
count: AtomicUsize,
}
<|fim_suffix|> vec![(filename, "1".... | code_fim | medium | {
"lang": "rust",
"repo": "BugenZhao/6.824-MapReduce",
"path": "/app-early-exit/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn reduce(&self, key: String, values: Vec<String>) -> String {
if key.contains("sherlock") || key.contains("tom") {
thread::sleep(Duration::from_secs(3));
}
values.len().to_string()
}
}
declare_app!(IndexerApp::default);<|fim_prefix|>// repo: BugenZhao/6.824-Ma... | code_fim | hard | {
"lang": "rust",
"repo": "BugenZhao/6.824-MapReduce",
"path": "/app-early-exit/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Selects the previous history entry. Save the current user (not yet executed)
/// input if needed.
pub fn prev(&mut self, user_input: &str) {
if self.offset == 0 {
// Entering the history selection. Save the current state.state.
self.user_input = user_input.... | code_fim | hard | {
"lang": "rust",
"repo": "agatan/nsh",
"path": "/src/history.rs",
"mode": "spm",
"license": "CC0-1.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.