text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>
impl Shortcut {
/// Create a shortcut from a char
pub fn from_char(c: char) -> Shortcut {
Shortcut::None | c
}
/// Create a shortcut from a key
pub fn from_key(k: Key) -> Shortcut {
Shortcut::None | k
}
/// Create a shortcut from an i32
pub fn from_i32(v:... | code_fim | hard | {
"lang": "rust",
"repo": "emartisoft/fltk-rs",
"path": "/fltk/src/enums.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emartisoft/fltk-rs path: /fltk/src/enums.rs
use crate::app::*;
use fltk_sys::fl::Fl_get_rgb_color;
/// Defines label types
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum LabelType {
Normal = 0,
None,
Shadow,
Engraved,
Embossed,
Multi,
Icon,
Image,... | code_fim | hard | {
"lang": "rust",
"repo": "emartisoft/fltk-rs",
"path": "/fltk/src/enums.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Defines event types captured by FLTK
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Event {
NoEvent = 0,
Push,
Released,
Enter,
Leave,
Drag,
Focus,
Unfocus,
KeyDown,
KeyUp,
Close,
Move,
Shortcut,
Deactivate,
Activate,
Hide... | code_fim | hard | {
"lang": "rust",
"repo": "emartisoft/fltk-rs",
"path": "/fltk/src/enums.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let f = Fraction::from(-2i32);
assert_eq!(Sign::Minus, f.sign().unwrap());
assert_eq!(2, *f.numer().unwrap());
assert_eq!(1, *f.denom().unwrap());
let f = Fraction::from(0i32);
assert_eq!(Sign::Plus, f.sign().unwrap());
assert_eq!(0, *f.numer().unwr... | code_fim | hard | {
"lang": "rust",
"repo": "dnsl48/fraction",
"path": "/src/fraction/generic_fraction.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dnsl48/fraction path: /src/fraction/generic_fraction.rs
{
GenericFraction::is_sign_negative(self)
}
}
impl<T: Clone + Integer + PartialEq + ToPrimitive> ToPrimitive for GenericFraction<T> {
fn to_i64(&self) -> Option<i64> {
match *self {
GenericFraction::NaN ... | code_fim | hard | {
"lang": "rust",
"repo": "dnsl48/fraction",
"path": "/src/fraction/generic_fraction.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dnsl48/fraction path: /src/fraction/generic_fraction.rs
;
Half => {Frac::new(1, 2)};
One => {Frac::new(1, 1)};
Two => {Frac::new(2, 1)};
Three => {Frac::new(3, 1)};
Four => {Frac::new(4, 1)};
);
#[test]
fn op_ord() {
let pin = Frac::in... | code_fim | hard | {
"lang": "rust",
"repo": "dnsl48/fraction",
"path": "/src/fraction/generic_fraction.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hodasemi/Context path: /presentation/src/presentationcore.rs
use crate::input::eventsystem::EventSystem;
use crate::prelude::*;
use crate::vri::openvrintegration::OpenVRIntegration;
use crate::wsi::windowsystemintegration::WindowSystemIntegration;
use crate::xri::openxrintegration::OpenXRIntegra... | code_fim | hard | {
"lang": "rust",
"repo": "hodasemi/Context",
"path": "/presentation/src/presentationcore.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
pub fn activate_vulkan_device_extensions(
&self,
extensions: &mut DeviceExtensions,
physical_device: &Arc<PhysicalDevice>,
) -> VerboseResult<()> {
match &self.backend {
PresentationBackend::Window(wsi) => {
wsi.acti... | code_fim | hard | {
"lang": "rust",
"repo": "hodasemi/Context",
"path": "/presentation/src/presentationcore.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/rayon/src/compile_fail/cannot_zip_filtered_data.rs
/
*
!
compile_fail
E0277
use
rayon
:
:
prelude
:
:
*
;
/
/
zip
requires
data
of
exact
size
but
<|fim_suffix|>
)
;
a
.
par_iter
(
)
.
zip
(
b
.
par_iter
(
)
.
filter
(
|
&
&
x
|
x
>
3
)
)
;
/
/
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/rayon/src/compile_fail/cannot_zip_filtered_data.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>>
=
(
0
.
.
1024
)
.
rev
(
)
.
collect
(
)
;
let
b
:
Vec
<
usize
>
=
(
0
.
.
1024
)
.
collect
(
)
;
a
.
par_iter
(
)
.
zip
(
b
.
par_iter
(
)
.
filter
(
|
&
&
x
|
x
>
3
)
)
;
/
/
~
ERROR
*
/<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/rayon/src/compile_fail/cannot_zip_filter... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/rayon/src/compile_fail/cannot_zip_filtered_data.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
)
;
a
.
par_iter
(
)
.
zip
(
b
.
par_iter
(
)
.
filter
(
|
&
&
x
|
x
>
3
)
)
;
/
/
~
ERROR
*
/<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/rayon/src/compile_fail/cannot_zip_filtered_data.rs
/
*
!
compile_fail
E0277
use
rayon
:
:
prelude
:
:
*
;
/
/
zip
requires
data
of
exac... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/rayon/src/compile_fail/cannot_zip_filtered_data.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !input_file.contains(&sep) && !input_file.contains("/") {
input_file = format!("{}{}", working_directory, input_file);
}
if !output_file.contains(&sep) && !output_file.contains("/") {
output_file = format!("{}{}", working_directory, output_file);
... | code_fim | hard | {
"lang": "rust",
"repo": "jblindsay/whitebox-tools",
"path": "/whitebox-tools-app/src/tools/data_tools/vector_points_to_raster.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jblindsay/whitebox-tools path: /whitebox-tools-app/src/tools/data_tools/vector_points_to_raster.rs
);
parameters.push(ToolParameter{
name: "Assignment Operation".to_owned(),
flags: vec!["--assign".to_owned()],
description: "Assignment operation, whe... | code_fim | hard | {
"lang": "rust",
"repo": "jblindsay/whitebox-tools",
"path": "/whitebox-tools-app/src/tools/data_tools/vector_points_to_raster.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.stream {
Some(ref mut s) => s.fill_buf(),
None => Err(io::Error::new(io::ErrorKind::NotConnected, "client not connected", None))
}
}
fn consume(&mut self, amt: usize) {
match self.stream {
Some(ref mut s) => s.consume(amt),
... | code_fim | hard | {
"lang": "rust",
"repo": "kstep/rust-bare-websocket",
"path": "/src/socket.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
pub fn connect(&mut self) -> io::Result<()> {
let mut nonce = Nonce::new();
try!(self.try_connect());
try!(self.write_request(&*nonce));
nonce = nonce.encode();
try!(self.read_response(&*nonce));
Ok(())
}
fn read_header(... | code_fim | hard | {
"lang": "rust",
"repo": "kstep/rust-bare-websocket",
"path": "/src/socket.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kstep/rust-bare-websocket path: /src/socket.rs
use std::io::{Read, Write, BufRead, BufStream, self};
use std::mem;
use std::collections::BTreeMap;
use std::u16;
use std::num::{Int, FromPrimitive, ToPrimitive};
use std::slice::SliceConcatExt;
use url::Url;
use rand::{thread_rng, Rng};
use nonce:... | code_fim | hard | {
"lang": "rust",
"repo": "kstep/rust-bare-websocket",
"path": "/src/socket.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tasdomas/sc path: /src/stack.rs
/// Stack contains a stack of elements
/// of the specified type.
pub struct Stack<T: Clone> {
S: Option<Box<StackElement<T>>>,
}
struct StackElement<T: Clone> {
value: T,
next: Stack<T>,
}
impl<T> Stack<T> where T: Clone {
/// new creates a ne... | code_fim | hard | {
"lang": "rust",
"repo": "tasdomas/sc",
"path": "/src/stack.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// pop removes an element from the stack and returns the rest of
/// the stack.
pub fn pop(self) -> (Stack<T>, Option<T>)
where T: Clone {
match self {
Stack{S: None} => (self, None),
Stack{S: Some(b)} => {
let el = *b;
... | code_fim | hard | {
"lang": "rust",
"repo": "tasdomas/sc",
"path": "/src/stack.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nwtnni/advent-of-code path: /aoc-20/src/day_19.rs
use std::collections::HashMap;
use aoc::*;
#[derive(Clone, Debug)]
pub struct MonsterMessages {
rules: HashMap<i64, Rule>,
messages: Vec<String>,
}
#[derive(Clone, Debug)]
enum Rule {
Leaf(char),
Tree(Vec<Vec<i64>>),
}
impl Fr... | code_fim | hard | {
"lang": "rust",
"repo": "nwtnni/advent-of-code",
"path": "/aoc-20/src/day_19.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if all && index == message.len() {
return true;
}
}
false
}
}
}
fn len(&self, rule: i64, memo: &mut HashMap<i64, usize>) -> usize {
if let Some(len) = memo.get(&rule).copied... | code_fim | hard | {
"lang": "rust",
"repo": "nwtnni/advent-of-code",
"path": "/aoc-20/src/day_19.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>EIGHT;
pub const LIMIT_FPS: i32 = 30;
pub const COLOR_DARK_WALL: Color = Color { r: 0, g: 0, b: 100 };
pub const COLOR_DARK_GROUND: Color = Color { r: 50, g: 50, b: 100 };<|fim_prefix|>// repo: gvmori/rl path: /src/config.rs
use tcod::colors::Color;
pub const SCREEN_WIDTH: i32 = 80;
pub const SCREEN_HE... | code_fim | medium | {
"lang": "rust",
"repo": "gvmori/rl",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gvmori/rl path: /src/config.rs
use tcod::colors::Color;
pub const SCREEN_WIDTH: i32 = 80;
pub const SCREEN_HEIGHT: i<|fim_suffix|>, g: 0, b: 100 };
pub const COLOR_DARK_GROUND: Color = Color { r: 50, g: 50, b: 100 };<|fim_middle|>32 = 60;
pub const MAP_WIDTH: i32 = SCREEN_WIDTH;
pub const MAP_H... | code_fim | medium | {
"lang": "rust",
"repo": "gvmori/rl",
"path": "/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nashenas88/coi path: /coi-test/tests/register_closure.rs
use coi::{container, provide_closure, Inject};
use std::sync::Arc;
pub trait Trait1: Inject {}
pub trait Trait2: Inject {}
#[allow(unused)]
#[derive(Inject)]
struct Impl {
trait2: Arc<dyn Trait2>,
data: String,
}
<|fim_suffix|>... | code_fim | hard | {
"lang": "rust",
"repo": "Nashenas88/coi",
"path": "/coi-test/tests/register_closure.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Inject)]
#[coi(provides dyn Trait2 with Impl2)]
struct Impl2;
impl Trait2 for Impl2 {}
#[test]
fn main() {
let x = String::from("3");
let trait1_provider = provide_closure!(
move |trait2: Arc<dyn Trait2>| -> coi::Result<Arc<dyn Trait1>> {
Ok(Arc::new(Impl::new(trait2... | code_fim | medium | {
"lang": "rust",
"repo": "Nashenas88/coi",
"path": "/coi-test/tests/register_closure.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raultang/actix-net path: /actix-ioframe/src/lib.rs
// #![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity, clippy::too_many_arguments)]
<|fim_suffix|>pub use self::connect::{Connect, ConnectResult};
pub use self::error::ServiceError;
pub use self::service::{Builder, FactoryBui... | code_fim | easy | {
"lang": "rust",
"repo": "raultang/actix-net",
"path": "/actix-ioframe/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::connect::{Connect, ConnectResult};
pub use self::error::ServiceError;
pub use self::service::{Builder, FactoryBuilder};<|fim_prefix|>// repo: raultang/actix-net path: /actix-ioframe/src/lib.rs
// #![deny(rust_2018_idioms, warnings)]
#![allow(clippy::type_complexity, clippy::too_many_argumen... | code_fim | easy | {
"lang": "rust",
"repo": "raultang/actix-net",
"path": "/actix-ioframe/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Error for SessionError {
fn description(&self) -> &str {
"session error"
}
fn cause(&self) -> Option<&dyn Error> {
match self {
SessionError::Io(err) => Some(err),
SessionError::CmdErr(err) => Some(err),
_ => None,
}
}
}
#[... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/undermoon",
"path": "/src/proxy/session.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut batch = stream::iter(replies.drain(..)).map(Ok);
if let Err(err) = writer.send_all(&mut batch).await {
error!("writer error: {}", err);
let err = match err {
EncodeError::Io(err) => SessionError::Io(err),
EncodeError::NotReady... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/undermoon",
"path": "/src/proxy/session.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gitter-badger/undermoon path: /src/proxy/session.rs
use super::backend::{CmdTask, CmdTaskFactory, CmdTaskResult};
use super::command::{
new_command_pair, CmdReplyReceiver, CmdReplySender, CmdType, Command, CommandError,
CommandResult, DataCmdType, TaskReply, TaskResult,
};
use super::dat... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/undermoon",
"path": "/src/proxy/session.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CreativeGP/kokmathlib path: /src/token.rs
/*
kokmathlib
2018/07/10 (yyyy/mm/dd)
Library for algebraic operations!
Author: CreativeGP(@CreativeGP1)
*/
use structs::*;
extern crate core;
extern crate regex;
use self::regex::Regex;
use std::str::FromStr;
impl FromStr for Token {
type E... | code_fim | medium | {
"lang": "rust",
"repo": "CreativeGP/kokmathlib",
"path": "/src/token.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let t1 = "3".parse::<Token>().unwrap();
let t2 = "x".parse::<Token>().unwrap();
// TODO: test for parenthesises
assert_eq!(format!("{:?}", t1), "Scalar(3)");
assert_eq!(format!("{:?}", t2), "Variable(\"x\")");
}<|fim_prefix|>// repo: CreativeGP/kokmathlib path: /src/token.rs
/*
kokm... | code_fim | medium | {
"lang": "rust",
"repo": "CreativeGP/kokmathlib",
"path": "/src/token.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn from_string() {
let t1 = "3".parse::<Token>().unwrap();
let t2 = "x".parse::<Token>().unwrap();
// TODO: test for parenthesises
assert_eq!(format!("{:?}", t1), "Scalar(3)");
assert_eq!(format!("{:?}", t2), "Variable(\"x\")");
}<|fim_prefix|>// repo: CreativeGP/kokmathlib ... | code_fim | hard | {
"lang": "rust",
"repo": "CreativeGP/kokmathlib",
"path": "/src/token.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aaronalbers/self-driving-car path: /brain/src/behavior/movement/aerial_loc_time.rs
#[cfg(test)]
mod integration_tests {
use crate::integration_tests::{TestRunner, TestScenario};
use common::prelude::*;
use nalgebra::Point3;
#[test]
#[ignore(note = "TODO")]
fn simple() {
... | code_fim | hard | {
"lang": "rust",
"repo": "aaronalbers/self-driving-car",
"path": "/brain/src/behavior/movement/aerial_loc_time.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let expected_loc = Point3::new(400.0, 1100.0, 600.0);
let test = TestRunner::new()
.scenario(TestScenario {
ball_loc: Point3::new(1000.0, 0.0, 0.0),
..Default::default()
})
.run_for_millis(3000);
let packet = test... | code_fim | medium | {
"lang": "rust",
"repo": "aaronalbers/self-driving-car",
"path": "/brain/src/behavior/movement/aerial_loc_time.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustWorks/butane path: /examples/getting_started/src/bin/delete_post.rs
use self::models::Post;
use butane::query;
use getting_started::*;
use std::env::args;
fn main() {
<|fim_suffix|> let conn = establish_connection();
let cnt = query!(Post, title.like({ pattern }))
.delete(&co... | code_fim | medium | {
"lang": "rust",
"repo": "RustWorks/butane",
"path": "/examples/getting_started/src/bin/delete_post.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let conn = establish_connection();
let cnt = query!(Post, title.like({ pattern }))
.delete(&conn)
.expect("error deleting posts");
println!("Deleted {} posts", cnt);
}<|fim_prefix|>// repo: RustWorks/butane path: /examples/getting_started/src/bin/delete_post.rs
use self::model... | code_fim | medium | {
"lang": "rust",
"repo": "RustWorks/butane",
"path": "/examples/getting_started/src/bin/delete_post.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: caibirdme/leetcode_rust path: /src/prob_474.rs
impl Solution {
pub fn find_max_form(strs: Vec<String>, m: i32, n: i32) -> i32 {
let len = strs.len();
if len == 0 {
return 0;
}
let mut f = vec![vec![0; m as usize+1]; n as usize+1];
for i in ... | code_fim | hard | {
"lang": "rust",
"repo": "caibirdme/leetcode_rust",
"path": "/src/prob_474.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_find_max_form() {
let test_cases = vec![
(vec!["10", "0001", "111001", "1", "0"], 5, 3, 4),
(vec!["10", "0", "1"], 1, 1, 2),
];
for (strs, m, n, expect) in test_cases {
assert_eq!(Solution::find_max_form(strs.iter().map(|v... | code_fim | hard | {
"lang": "rust",
"repo": "caibirdme/leetcode_rust",
"path": "/src/prob_474.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let test_cases = vec![
(vec!["10", "0001", "111001", "1", "0"], 5, 3, 4),
(vec!["10", "0", "1"], 1, 1, 2),
];
for (strs, m, n, expect) in test_cases {
assert_eq!(Solution::find_max_form(strs.iter().map(|v| v.to_string()).collect(), m, n), expect,... | code_fim | hard | {
"lang": "rust",
"repo": "caibirdme/leetcode_rust",
"path": "/src/prob_474.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Represents a window used to control inputs.
#[allow(dead_code)]
pub struct Controller<'a> {
base_window: CppBox<QWidget>,
inputs: &'a Arc<Mutex<Inputs>>,
buttons: ButtonPanel<'a>,
joystick: JoystickPanel<'a>,
}
impl<'a> Controller<'a> {
/// Instantiate a new controller
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "notgull/tasinput2",
"path": "/src/controller/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: notgull/tasinput2 path: /src/controller/mod.rs
/*
* src/controller/mod.rs
* tasinput2 - Plugin for creating TAS inputs
*
* This file is part of tasinput2.
*
* tasinput2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as publis... | code_fim | hard | {
"lang": "rust",
"repo": "notgull/tasinput2",
"path": "/src/controller/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Liby99/llir path: /src/utils/mem_buffer.rs
use llvm_sys::core::{LLVMCreateMemoryBufferWithContentsOfFile, LLVMDisposeMemoryBuffer};
use llvm_sys::prelude::LLVMMemoryBufferRef;
use super::support::{to_c_str, LLVMString};
use std::mem::MaybeUninit;
use std::path::Path;
use std::ptr;
#[derive(De... | code_fim | hard | {
"lang": "rust",
"repo": "Liby99/llir",
"path": "/src/utils/mem_buffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use std::mem::MaybeUninit;
use std::path::Path;
use std::ptr;
#[derive(Debug)]
pub struct MemoryBuffer {
pub(crate) memory_buffer: LLVMMemoryBufferRef,
}
impl MemoryBuffer {
pub(crate) fn new(memory_buffer: LLVMMemoryBufferRef) -> Self {
assert!(!memory_buffer.is_null());
MemoryBuffer { mem... | code_fim | medium | {
"lang": "rust",
"repo": "Liby99/llir",
"path": "/src/utils/mem_buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yk-amarly-20/Rust-practice path: /practice/step3/src/main.rs
fn main() {
// データ型
// 浮動少数点数
let x = 2.0; // 倍精度 f64
let y: f32 = 3.0; // 単精度 f32
// bool
let t = true;
let f: bool = false;
<|fim_suffix|> // タプル
let tup: (i32, f64, u8) = (500, 6.4, 1);
... | code_fim | medium | {
"lang": "rust",
"repo": "yk-amarly-20/Rust-practice",
"path": "/practice/step3/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("The value of y is {}", y);
let five_hundred = tup.0;
let six_point_four = tup.1;
let one = tup.2;
// 配列
// 固定長
let a = [1, 2, 3, 4, 5];
let first = a[0];
let second = a[1];
// 配列の長さ以上のindexを指定するとパニック
}<|fim_prefix|>// repo: yk-amarly-20/Rust-practice p... | code_fim | hard | {
"lang": "rust",
"repo": "yk-amarly-20/Rust-practice",
"path": "/practice/step3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let meta = entry.metadata().ok()?;
if meta.is_file() {
Some((entry.into_path(), meta.modified().ok()?))
} else {
None
}
}
fn ensure_directories<'a>(path: &'a Path, cache: &mut HashSet<PathBuf>) -> io::Result<()> {
let directory = if path.is_dir() {
path
} e... | code_fim | hard | {
"lang": "rust",
"repo": "archer884/copy-changes",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: archer884/copy-changes path: /src/main.rs
use hashbrown::{HashMap, HashSet};
use std::path::{Path, PathBuf};
use std::time::SystemTime;
use std::{fs, io};
use structopt::StructOpt;
use walkdir::{DirEntry, WalkDir};
#[derive(Debug, StructOpt)]
struct Opt {
from: String,
to: String,
#... | code_fim | hard | {
"lang": "rust",
"repo": "archer884/copy-changes",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pwoolcoc/tantivy path: /src/query/query_parser/mod.rs
mod query_grammar;
mod query_parser;
mod <|fim_suffix|> use self::query_parser::QueryParserError;<|fim_middle|>user_input_ast;
pub mod logical_ast;
pub use self::query_parser::QueryParser;
pub | code_fim | medium | {
"lang": "rust",
"repo": "pwoolcoc/tantivy",
"path": "/src/query/query_parser/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use self::query_parser::QueryParserError;<|fim_prefix|>// repo: pwoolcoc/tantivy path: /src/query/query_parser/mod.rs
mod query_grammar;
mod query_parser;
mod user_input_ast;
pub mod logical_ast;
pub<|fim_middle|> use self::query_parser::QueryParser;
pub | code_fim | easy | {
"lang": "rust",
"repo": "pwoolcoc/tantivy",
"path": "/src/query/query_parser/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Start renderer, move into it's own thread.
let renderer = Renderer::new(io::stdout(), rx_checked, source.clone())?;
// Acquire handle to ensure terminal is restored when we are done.
let renderer_handle = thread::spawn(move || renderer.run());
// Start checker, move into it's own th... | code_fim | hard | {
"lang": "rust",
"repo": "Lainera/typist",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lainera/typist path: /src/main.rs
use std::sync::mpsc::{channel, sync_channel, Receiver, Sender, SyncSender};
use std::sync::Arc;
use std::{io, thread};
use termion::input::TermRead;
// local
mod checker;
mod parser;
mod renderer;
mod source;
use checker::{Checker, Control};
use parser::{Parsed... | code_fim | hard | {
"lang": "rust",
"repo": "Lainera/typist",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// https://cdn.skypack.dev/-/@darkforest_eth/contracts@v6.2.9-beYRQYHGj7ONrOAiAcwi/dist=es2020,mode=imports/optimized/@darkforest_eth/contracts.js
impl Config {
/// Provides the smart contract addresses for Dark Forest 0.6r2 on xDAI
pub fn xdai() -> Self {
Self {
start_block: 1... | code_fim | hard | {
"lang": "rust",
"repo": "cleancoindev/dark-forest",
"path": "/crates/df-contracts/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cleancoindev/dark-forest path: /crates/df-contracts/src/config.rs
use crate::addr;
use ethers::types::Address;
/// The networks where the Dark Forest contracts are deployed at
pub enum Network {
/// [XDai](https://www.xdaichain.com/) is a PoA Ethereum sidechain using DAI as its fee token
... | code_fim | hard | {
"lang": "rust",
"repo": "cleancoindev/dark-forest",
"path": "/crates/df-contracts/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let new_position = cart.move_one_tick(&track);
positions.pop_front();
positions.push_back(new_position);
if check_if_carts_collide(&positions) {
if first_crash {
println!("Part 1: {:?}", new_position);
... | code_fim | hard | {
"lang": "rust",
"repo": "konradsz/adventofcode2018",
"path": "/day13/carts.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for cart in carts.iter_mut() {
if crashed.contains(&(cart.x, cart.y)) {
continue;
}
let new_position = cart.move_one_tick(&track);
positions.pop_front();
positions.push_back(new_position);
if check_if_carts_c... | code_fim | hard | {
"lang": "rust",
"repo": "konradsz/adventofcode2018",
"path": "/day13/carts.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: konradsz/adventofcode2018 path: /day13/carts.rs
use std::collections::HashSet;
use std::collections::VecDeque;
use std::fs;
use std::iter::FromIterator;
#[derive(PartialEq)]
enum TrackElement {
Vertical,
Horizontal,
Backslash,
Slash,
Intersection,
Empty,
}
enum Intersec... | code_fim | hard | {
"lang": "rust",
"repo": "konradsz/adventofcode2018",
"path": "/day13/carts.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: l1nxy/OJ-solution path: /code-wars/rust/rust_consecutive_strings/src/main.rs
fn longest_consec(strarr: Vec<&str>, k: usize) -> String {
let mut v = strarr.clone();
let mut ret = String::new();
let len = strarr.len();
if k <= 0 || k > len || len == 0 {
return String::from(... | code_fim | medium | {
"lang": "rust",
"repo": "l1nxy/OJ-solution",
"path": "/code-wars/rust/rust_consecutive_strings/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: newAM/r3 path: /src/r3_port_arm/src/arm/bpiall.rs
/// Branch predictor invalidate all
pub const BPIALL: BPIAL<|fim_suffix|>l register::cpu::RegisterWriteOnly<u32, ()> for BPIALLAccessor {
sys_coproc_write_raw!(u32, [p15, c7, 0, c5, 6]);
}<|fim_middle|>LAccessor = BPIALLAccessor;
pub struct B... | code_fim | easy | {
"lang": "rust",
"repo": "newAM/r3",
"path": "/src/r3_port_arm/src/arm/bpiall.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>sor {
sys_coproc_write_raw!(u32, [p15, c7, 0, c5, 6]);
}<|fim_prefix|>// repo: newAM/r3 path: /src/r3_port_arm/src/arm/bpiall.rs
/// Branch predictor invalidate all
pub const BPIALL: BPIALLAccessor = BPIALLAccessor;
pub struct BPIALLAccessor;
imp<|fim_middle|>l register::cpu::RegisterWriteOnly<u32, ... | code_fim | easy | {
"lang": "rust",
"repo": "newAM/r3",
"path": "/src/r3_port_arm/src/arm/bpiall.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if dynsym_str == "__occlum_syscall" {
let rela_addr = process_base_addr + rela_entry.get_offset() as usize;
unsafe {
ptr::write_unaligned(rela_addr as *mut usize, syscall_addr);
}
}
}
Ok(())
}
extern "C" {
fn __occlum_syscal... | code_fim | hard | {
"lang": "rust",
"repo": "occlum/occlum",
"path": "/src/libos/src/process/do_spawn/init_vm.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: occlum/occlum path: /src/libos/src/process/do_spawn/init_vm.rs
use std::ptr;
use super::super::elf_file::ElfFile;
use crate::misc::{resource_t, rlimit_t};
use crate::prelude::*;
use crate::vm::{ProcessVM, ProcessVMBuilder};
pub fn do_init<'a, 'b>(
elf_file: &'b ElfFile<'a>,
ldso_elf_fi... | code_fim | hard | {
"lang": "rust",
"repo": "occlum/occlum",
"path": "/src/libos/src/process/do_spawn/init_vm.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>";
// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = PathBuf::from("../src").join("bindings.rs");
let mut output_file =
File::create(&out_path).expect(&format!("Couldn't create {:?}", out_path));
output_file
.write_all(header)
.expect("Couldn'... | code_fim | hard | {
"lang": "rust",
"repo": "dgreid/adhd",
"path": "/sof_sys/generator/src/main.rs",
"mode": "spm",
"license": "BSD-1-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dgreid/adhd path: /sof_sys/generator/src/main.rs
// Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern crate bindgen;
use std::fs::File;
use std::io::Write;
use std::path::Pa... | code_fim | hard | {
"lang": "rust",
"repo": "dgreid/adhd",
"path": "/sof_sys/generator/src/main.rs",
"mode": "psm",
"license": "BSD-1-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dcao/elba-web path: /src/router.rs
use actix_web::{http::Method, App};
use crate::controller;
use crate::util::async_await::compat;
use crate::AppState;
pub fn router(app: App<AppState>) -> App<AppState> {
app.prefix("/api/v1")
.route(
"/users/login",
Method... | code_fim | hard | {
"lang": "rust",
"repo": "dcao/elba-web",
"path": "/src/router.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ackages::metadata::list_packages),
)
.route(
"/packages/{group}/{package}/metadata",
Method::GET,
compat(controller::packages::metadata::show_package),
)
.route(
"/packages/{group}/{package}/versions",
Method::GET,... | code_fim | hard | {
"lang": "rust",
"repo": "dcao/elba-web",
"path": "/src/router.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frankier/wikiparse path: /dumpsplit/src/main.rs
#[macro_use] extern crate lazy_static;
use std::env;
use std::path::Path;
use std::str;
use std::fs::{create_dir_all, File};
use std::io::prelude::*;
use std::io::{self, BufReader};
use std::iter::Iterator;
use std::str::from_utf8;
use twoway::fi... | code_fim | hard | {
"lang": "rust",
"repo": "frankier/wikiparse",
"path": "/dumpsplit/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
match reader.read_event(&mut buf) {
Ok(Event::Start(ref e)) => {
match e.name() {
b"page" => {
revisions = 0;
count += 1;
}
b"title" => {
... | code_fim | hard | {
"lang": "rust",
"repo": "frankier/wikiparse",
"path": "/dumpsplit/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> info!("Loading vmc...");
let start_vmc = Instant::now();
let (height, meta) = {
let mut vmc_base = BufReader::new(File::open(&config.path_vmc).unwrap());
info!("\tLoading compression tables...");
let mut st_table = Vec::<i32>::with_capacity(size.1 as usize);
let... | code_fim | hard | {
"lang": "rust",
"repo": "lpenguin/vange-rs",
"path": "/src/level/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lpenguin/vange-rs path: /src/level/mod.rs
use byteorder::{LittleEndian as E, ReadBytesExt};
use std::io::{BufReader, Read, Seek, SeekFrom};
mod config;
pub use self::config::{LevelConfig, TerrainConfig};
pub const NUM_TERRAINS: usize = 8;
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Eq)]
pu... | code_fim | hard | {
"lang": "rust",
"repo": "lpenguin/vange-rs",
"path": "/src/level/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<V, D> TcpStreamInboundWire<V, D>
where
V: Verifier,
D: Decrypter,
{
pub fn new(
inbound_wire: InboundWire<V, D>,
stream: ReadHalf<TcpStream>,
remote_addr: SocketAddr,
) -> Self {
Self {
inbound_wire,
stream,
remote_ad... | code_fim | hard | {
"lang": "rust",
"repo": "chipsenkbeil/over-there",
"path": "/src/core/transport/wire/tcp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct TcpStreamOutboundWire<S, E>
where
S: Signer,
E: Encrypter,
{
outbound_wire: OutboundWire<S, E>,
stream: WriteHalf<TcpStream>,
}
impl<S, E> TcpStreamOutboundWire<S, E>
where
S: Signer,
E: Encrypter,
{
pub fn new(
outbound_wire: OutboundWire<S, E>,
str... | code_fim | hard | {
"lang": "rust",
"repo": "chipsenkbeil/over-there",
"path": "/src/core/transport/wire/tcp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chipsenkbeil/over-there path: /src/core/transport/wire/tcp.rs
use super::{
auth, crypto, Authenticator, Bicrypter, Decrypter, Encrypter, InboundWire,
InboundWireError, OutboundWire, OutboundWireError, Signer, Verifier, Wire,
};
use std::net::SocketAddr;
use tokio::{
io::{self, AsyncR... | code_fim | hard | {
"lang": "rust",
"repo": "chipsenkbeil/over-there",
"path": "/src/core/transport/wire/tcp.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simmsb/toohoo path: /src/systems/velocity_capper.rs
use amethyst::derive::SystemDesc;
use amethyst::ecs::{Join, ReadStorage, System, SystemData, WriteStorage};
<|fim_suffix|> fn run(&mut self, (mut velocities, caps): Self::SystemData) {
for (velocity, cap) in (&mut velocities, &caps)... | code_fim | hard | {
"lang": "rust",
"repo": "simmsb/toohoo",
"path": "/src/systems/velocity_capper.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (velocity, cap) in (&mut velocities, &caps).join() {
*velocity = cap.cap(*velocity);
}
}
}<|fim_prefix|>// repo: simmsb/toohoo path: /src/systems/velocity_capper.rs
use amethyst::derive::SystemDesc;
use amethyst::ecs::{Join, ReadStorage, System, SystemData, WriteStorag... | code_fim | medium | {
"lang": "rust",
"repo": "simmsb/toohoo",
"path": "/src/systems/velocity_capper.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut blocks = banks[index];
banks[index] = 0;
while blocks > 0 {
index = (index + 1) % banks.len();
banks[index] += 1;
blocks -= 1;
}
count += 1;
}
if part1 {
return count;
}
return count - hash_map.... | code_fim | hard | {
"lang": "rust",
"repo": "annesummers/advent-of-code-2017",
"path": "/src/day6/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: annesummers/advent-of-code-2017 path: /src/day6/mod.rs
use file;
use std::collections::hash_map::HashMap;
use time;
pub fn run() {
let inputs = file::read_inputs("Day6.txt");
println!("Answer {}", solve(&"0\t2\t7\t0".to_string(), true));
println!("Answer {}", solve(&"0\t2\t7\t0".to... | code_fim | medium | {
"lang": "rust",
"repo": "annesummers/advent-of-code-2017",
"path": "/src/day6/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/rust-dangerous path: /src/input/maybe.rs
use crate::display::InputDisplay;
use crate::fmt;
use super::{Bound, Bytes, Input, String};
/// [`String`] if known UTF-8, [`Bytes`] if not.
#[derive(Clone)]
#[must_use = "input must be consumed"]
pub enum MaybeString<'i> {
/// The [`Input`]... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/rust-dangerous",
"path": "/src/input/maybe.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "retry")]
pub(crate) fn is_bound(&self) -> bool {
self.bound() == Bound::Both
}
pub(crate) fn bound(&self) -> Bound {
match self {
Self::Bytes(v) => v.bound(),
Self::String(v) => v.bound(),
}
}
}
////////////////////////... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/rust-dangerous",
"path": "/src/input/maybe.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl EventHandler<ggez::GameError> for MyGame {
fn update(&mut self, ctx: &mut Context) -> GameResult {
while ctx.time.check_update_time(120) {
for star in &mut self.stars {
star.z -= 0.3;
if star.z <= 0.0 {
star.x = xy_range();
... | code_fim | hard | {
"lang": "rust",
"repo": "JohnMeyerhoff/starfield",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut stars: Vec<Star> = vec![];
for _ in 0..STARS_COUNT {
stars.push(Star::new());
}
MyGame { stars }
}
fn get_next_color(r: u8, g: u8, b: u8) -> Color {
Color::from_rgba(r, g, b, 255)
}
}
impl EventHandler<ggez::GameError> for MyGame {
... | code_fim | hard | {
"lang": "rust",
"repo": "JohnMeyerhoff/starfield",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JohnMeyerhoff/starfield path: /src/main.rs
extern crate ggez;
extern crate rand;
use ggez::event::{self, EventHandler};
use ggez::graphics::{Color, Rect};
use ggez::{conf, graphics};
use ggez::{Context, ContextBuilder, GameResult};
use rand::Rng;
const WIDTH: f32 = 620.0;
const HEIGHT: f32 = ... | code_fim | hard | {
"lang": "rust",
"repo": "JohnMeyerhoff/starfield",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn atomic_u64_u64(c: &mut Criterion) {
let heatmap = AtomicHeatmap::<u64, AtomicU64>::new(
1_000_000,
2,
Duration::new(1, 0),
Duration::from_millis(1),
);
let mut group = c.benchmark_group("AtomicHeatmap/u64/AtomicU64");
group.throughput(Throughput::Elemen... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/rustcommon",
"path": "/heatmap/benches/heatmaps.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doytsujin/rustcommon path: /heatmap/benches/heatmaps.rs
use core::time::Duration;
use criterion::Throughput;
use criterion::{criterion_group, criterion_main, Criterion};
use rustcommon_heatmap::*;
use std::time::Instant;
fn u64_u64(c: &mut Criterion) {
<|fim_suffix|> group.throughput(Through... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/rustcommon",
"path": "/heatmap/benches/heatmaps.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pc += 4
}
numbers[0]
}
pub fn star_one(input: &str) -> isize {
let program = parse_custom_separated::<isize>(input, ",").collect();
let mut computer = Computer::with_input(program, || Some(1));
computer.run_until_halt_or_paused(false);
computer.memory().read(0)
}
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "k0nserv/advent-of-rust-2019",
"path": "/src/day02.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: k0nserv/advent-of-rust-2019 path: /src/day02.rs
use crate::intcode_computer::Computer;
use crate::parse_custom_separated;
use itertools::iproduct;
fn run_until_halt(memory: Vec<i64>) -> i64 {
let mut numbers: Vec<i64> = memory;
let mut pc = 0;
<|fim_suffix|>pub fn star_two(input: &str)... | code_fim | hard | {
"lang": "rust",
"repo": "k0nserv/advent-of-rust-2019",
"path": "/src/day02.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (noun, verb) = iproduct!((0..=99), (0..=99))
.find(|&(noun, verb)| {
let mut modified_computer = Computer::with_input(program.clone(), || Some(1));
modified_computer.memory().write(1, noun);
modified_computer.memory().write(2, verb);
modifie... | code_fim | medium | {
"lang": "rust",
"repo": "k0nserv/advent-of-rust-2019",
"path": "/src/day02.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/ApplicationModel/Preview/mod.rs
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[cfg(feature = "ApplicationModel_Preview_Holog<|fim_suffix|>
pub mod InkWorkspace;
#[cf... | code_fim | medium | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/ApplicationModel/Preview/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub mod InkWorkspace;
#[cfg(feature = "ApplicationModel_Preview_Notes")]
pub mod Notes;<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/ApplicationModel/Preview/mod.rs
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, ... | code_fim | medium | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/ApplicationModel/Preview/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(unused_variables)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Error {
BufferTooShort,
InvalidMagic,
InvalidClass,
}<|fim_prefix|>// repo: VenmoTools/OperatingSystem path: /uefis/src/elf/mod.rs
pub use elf32::*;
pub use elf64::*;
pub use elf_type::*;
pub use flags::*;
pub us... | code_fim | medium | {
"lang": "rust",
"repo": "VenmoTools/OperatingSystem",
"path": "/uefis/src/elf/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VenmoTools/OperatingSystem path: /uefis/src/elf/mod.rs
pub use elf32::*;
pub use elf64::*;
pub use elf_type::*;
pub use flags::*;
pub use segment::*;
pub use traits::*;
<|fim_suffix|>#[allow(unused_variables)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Error {
BufferTooShort,
... | code_fim | medium | {
"lang": "rust",
"repo": "VenmoTools/OperatingSystem",
"path": "/uefis/src/elf/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yanbowen1994/async_file_test path: /src/main.rs
use futures::future::join_all;
use std::time::Instant;
use rand::Rng;
use std::fs::OpenOptions;
use std::io::Write;
mod async_file {
use async_std::prelude::*;
use futures::TryFutureExt;
use async_std::io::{ErrorKind, self, SeekFrom};
... | code_fim | hard | {
"lang": "rust",
"repo": "yanbowen1994/async_file_test",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = async_std::task::block_on(join_all(
randoms
.chunks(1024)
.into_iter()
.map(|random| {
async_file::read_file(file_path, random)
})
.collect::<Vec<_>>()
));
let res = res.into_iter()
.map(|tas... | code_fim | hard | {
"lang": "rust",
"repo": "yanbowen1994/async_file_test",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mwatts/makepad path: /studio/editor_core/src/delta.rs
Delta::default()
}
/// Returns an iterator over the ranges of the operations in this delta, and their kind.
///
/// The range of an operation is defined as follows: for an insert operation, it is the range
//... | code_fim | hard | {
"lang": "rust",
"repo": "mwatts/makepad",
"path": "/studio/editor_core/src/delta.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// This is the operational transform function that forms the heart of operational transform
/// (OT). Given a pair of deltas (A, B) that were defined with respect to the same text, it
/// returns a new pair of deltas (A', B'), such that applying A' after B has the same effect
/// as apply... | code_fim | hard | {
"lang": "rust",
"repo": "mwatts/makepad",
"path": "/studio/editor_core/src/delta.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mwatts/makepad path: /studio/editor_core/src/delta.rs
ose(delta_1);
///
/// let mut text = Text::from("abc");
/// text.apply_delta(composite_delta);
/// assert_eq!(text, Text::from("abcdefghi"));
/// ```
pub fn compose(self, other: Delta) -> Delta {
let mut builde... | code_fim | hard | {
"lang": "rust",
"repo": "mwatts/makepad",
"path": "/studio/editor_core/src/delta.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO handle cursor
ResponseTemplate::new(200).set_body_json(json!({
"result": {
"data": responses ,
"cursor": {
"limit": 100,
"after": null,
"before": null,
"orde... | code_fim | hard | {
"lang": "rust",
"repo": "sjoerdsimons/phabricator-rs",
"path": "/phabricator-mock/src/api/edge.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sjoerdsimons/phabricator-rs path: /phabricator-mock/src/api/edge.rs
use crate::*;
use serde_json::json;
pub struct Search;
impl PhabRespond for Search {
fn respond(&self, server: &PhabMockServer, params: &Params, _: &Request) -> ResponseTemplate {
const SUBTASK: &str = "task.subtask... | code_fim | hard | {
"lang": "rust",
"repo": "sjoerdsimons/phabricator-rs",
"path": "/phabricator-mock/src/api/edge.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if types
.iter()
.any(|t| ![PARENT, SUBTASK].contains(&t.as_str()))
{
panic!("Unrecognized type in {:?}", types);
}
let mut responses = Vec::new();
for phid in sources {
let phid = phid.parse().expect("Couldn't parse ... | code_fim | hard | {
"lang": "rust",
"repo": "sjoerdsimons/phabricator-rs",
"path": "/phabricator-mock/src/api/edge.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: csivitu/pls.give path: /src/commands/link.rs
use serenity::framework::standard::{macros::command, Args, CommandResult};
use serenity::model::prelude::*;
use serenity::prelude::*;
use isahc::prelude::*;
use std::time::Duration;
use url::Url;
use tokio::task;
type Result<T> = std::result::Resul... | code_fim | medium | {
"lang": "rust",
"repo": "csivitu/pls.give",
"path": "/src/commands/link.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn get_link(link: String) -> Result<String> {
let url_parse = Url::parse(&link);
if url_parse.is_err() {
return Ok(String::from("Invalid URL format"))
}
let mut response = Request::post("http://gg.gg/create")
.timeout(Duration::from_secs(5))
.body(forma... | code_fim | medium | {
"lang": "rust",
"repo": "csivitu/pls.give",
"path": "/src/commands/link.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.