text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: joshterrell805-historic/rust path: /tic-tac-toe/src/main.rs
mod tic_tac_toe;
<|fim_suffix|> // let mut board = Board {
// moves: [(Mark::None, Player::One) ; 9],
// };
// board.moves[0] = (Mark::None, Player::Two);
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "joshterrell805-historic/rust",
"path": "/tic-tac-toe/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // let mut board = Board {
// moves: [(Mark::None, Player::One) ; 9],
// };
// board.moves[0] = (Mark::None, Player::Two);
}<|fim_prefix|>// repo: joshterrell805-historic/rust path: /tic-tac-toe/src/main.rs
mod tic_tac_toe;
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "joshterrell805-historic/rust",
"path": "/tic-tac-toe/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn world_bounds_for_transform(transform: Matrix2d) -> (Vec2d, Vec2d) {
// in the end transform matrix has to translate all points into (-1, 1) range
// this function reverses the matrix assuming it doesn't have any rotation, aka it's of the form:
// [ A 0 B ]
// [ 0 C D ]
// x is in th... | code_fim | hard | {
"lang": "rust",
"repo": "deasilgame/deasil",
"path": "/src/frontend_piston/rendering.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deasilgame/deasil path: /src/frontend_piston/rendering.rs
extern crate graphics;
extern crate opengl_graphics;
extern crate specs;
use self::graphics::math::{Matrix2d, Vec2d};
use self::graphics::{Graphics, Transformed, Viewport};
use self::opengl_graphics::{GlGraphics, OpenGL};
use self::specs... | code_fim | hard | {
"lang": "rust",
"repo": "deasilgame/deasil",
"path": "/src/frontend_piston/rendering.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // hash_bytes is [u8; 8] so copy it twice into an output array
let mut output = [0u8; 16];
for (from, to) in hash_bytes.iter().chain(&hash_bytes).zip(output.iter_mut()) {
*to = *from;
}
output
}
}
fn world_bounds_for_transform(transform: Matrix2d) -... | code_fim | hard | {
"lang": "rust",
"repo": "deasilgame/deasil",
"path": "/src/frontend_piston/rendering.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> roman_string += &add_all_of_one_type(&mut int_value, 1000, String::from("M"));
roman_string += &add_all_of_one_type(&mut int_value, 500, String::from("D"));
roman_string += &add_all_of_one_type(&mut int_value, 100, String::from("C"));
roman_string += &add_all_of_one_type(&mut int_value, 50... | code_fim | hard | {
"lang": "rust",
"repo": "JosephTLyons/Interview_Question_Solutions",
"path": "/byte_by_byte/Easy/integer_to_roman_numerals/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JosephTLyons/Interview_Question_Solutions path: /byte_by_byte/Easy/integer_to_roman_numerals/src/main.rs
// Given an integer, write a function to return its roman numeral representation.
// Incorrect, not solved
// Mapping:
// 1 -> I
// 5 -> V
// 10 -> X
// 50 -> L
// 100 -> C
// 500... | code_fim | medium | {
"lang": "rust",
"repo": "JosephTLyons/Interview_Question_Solutions",
"path": "/byte_by_byte/Easy/integer_to_roman_numerals/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jlopezscala/rust-book path: /chapter3_common_concepts/src/temperature_converter.rs
use std::io;
use std::process::exit;
use crate::parsers::{parse_integer_input, parse_float_input};
<|fim_suffix|> let option = parse_integer_input();
if option == 1 {
println!("Insert Celsius tempe... | code_fim | medium | {
"lang": "rust",
"repo": "jlopezscala/rust-book",
"path": "/chapter3_common_concepts/src/temperature_converter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let option = parse_integer_input();
if option == 1 {
println!("Insert Celsius temperature");
let input = parse_float_input();
let result = (input * 9.0 / 5.0) + 32.0;
println!("{} Celsius in Farenheit is {}", input, result)
} else if option == 2 {
printl... | code_fim | medium | {
"lang": "rust",
"repo": "jlopezscala/rust-book",
"path": "/chapter3_common_concepts/src/temperature_converter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nuncjo/RustVsPython path: /rust/errors_handling/src/main.rs
use std::fs::File;
use std::error::Error;
use std::io::Write;
fn raise_error() {
let x = 1;
let y = 0;
if y == 0 {
panic!("Division by zero occured, exiting");
} else {
print!("{} / {} = {}", x, y, x/y)... | code_fim | hard | {
"lang": "rust",
"repo": "nuncjo/RustVsPython",
"path": "/rust/errors_handling/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn handle_error_question_mark() -> Result<String, Box<Error>> {
try!(File::create("src/example_try.txt")).write_all(b"Just a test!");
// question mark is shorter try!
File::create("src/example.txt")?.write_all(b"Just another test!");
/*
works like:
match File::create("src/example.... | code_fim | hard | {
"lang": "rust",
"repo": "nuncjo/RustVsPython",
"path": "/rust/errors_handling/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> animators
.iter_mut()
.zip_entity(defense_colliders)
.for_each(|(_, animator, collider)| {
if let Some(id) = animator.playing_id() {
if id == CharacterAnimID::Damaged && animator.is_end() {
animator.pla... | code_fim | hard | {
"lang": "rust",
"repo": "mas-yo/rust-ecs-game",
"path": "/src/systems.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mas-yo/rust-ecs-game path: /src/systems.rs
use crate::components::*;
use crate::*;
use std::marker::PhantomData;
pub(crate) trait SystemInterface {
type Update;
type Refer;
}
pub(crate) trait SystemProcess: SystemInterface {
fn process(update: &mut Self::Update, _ref: &Self::Refer);... | code_fim | hard | {
"lang": "rust",
"repo": "mas-yo/rust-ecs-game",
"path": "/src/systems.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> body_weapon_colliders.iter().zip_entity(teams).for_each(|(weapon_entity_id, weapon_collider, weapon_team)|{
if defense_entity_id == weapon_entity_id {
return;
}
if defense_team.team_id() == weapon_team.team... | code_fim | hard | {
"lang": "rust",
"repo": "mas-yo/rust-ecs-game",
"path": "/src/systems.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Monadic-Cat/mice path: /benches/my_benchmark.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
<|fim_suffix|>criterion_group!(benches, rolling_benchmark);
criterion_main!(benches);<|fim_middle|>fn rolling_benchmark(c: &mut Criterion) {
c.bench_function("rolls", |b| ... | code_fim | medium | {
"lang": "rust",
"repo": "Monadic-Cat/mice",
"path": "/benches/my_benchmark.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>criterion_group!(benches, rolling_benchmark);
criterion_main!(benches);<|fim_prefix|>// repo: Monadic-Cat/mice path: /benches/my_benchmark.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
fn rolling_benchmark(c: &mut Criterion) {
<|fim_middle|> c.bench_function("rolls", |b| ... | code_fim | medium | {
"lang": "rust",
"repo": "Monadic-Cat/mice",
"path": "/benches/my_benchmark.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fnichol/artifetch path: /src/app/handlers/assets.rs
use crate::app::{self, paths};
use actix_web::{http, web, Error, HttpResponse};
use futures::{future, Future};
<|fim_suffix|>pub fn get_asset(
path: web::Path<paths::Asset>,
data: web::Data<app::Data>,
) -> impl Future<Item = HttpRespo... | code_fim | hard | {
"lang": "rust",
"repo": "fnichol/artifetch",
"path": "/src/app/handlers/assets.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_asset(
path: web::Path<paths::Asset>,
data: web::Data<app::Data>,
) -> impl Future<Item = HttpResponse, Error = Error> {
future::result(paths::get_asset(path.as_ref(), &data)).and_then(|asset| {
HttpResponse::Found()
.header(http::header::LOCATION, asset.download... | code_fim | hard | {
"lang": "rust",
"repo": "fnichol/artifetch",
"path": "/src/app/handlers/assets.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hacspec/hacspec path: /language/language-tests/enums.rs
use hacspec_lib::*;
pub enum Baz {
CaseX,
CaseY(Result<u8, U8>),
}
pub enum Foo {
CaseX(Baz),
CaseY(u8, Seq<u32>),
}
pub struct Bar(pub u32);
pub fn baz(x: Foo) -> Bar {
let z: Bar = Bar(0u32);
let Bar(z) = z;
... | code_fim | hard | {
"lang": "rust",
"repo": "hacspec/hacspec",
"path": "/language/language-tests/enums.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn match_integers_u8(x: u8) -> u8 {
match x {
0u8 => 1u8,
1u8 => 2u8,
_ => 0u8,
}
}
pub fn baz_im(x: Foo) {
let z: Bar = Bar(0u32);
let Bar(z) = z;
let a = z as u8;
}
struct Foobar(u8, u8, u8);
fn field_accessors() -> u8 {
Foobar(0u8, 1u8, 2u8).0 + Fo... | code_fim | hard | {
"lang": "rust",
"repo": "hacspec/hacspec",
"path": "/language/language-tests/enums.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn match_integers_usize(x: usize) -> usize {
match x {
0 => 1,
1 => 2,
_ => 0,
}
}
pub fn match_integers_u8(x: u8) -> u8 {
match x {
0u8 => 1u8,
1u8 => 2u8,
_ => 0u8,
}
}
pub fn baz_im(x: Foo) {
let z: Bar = Bar(0u32);
let Bar(z... | code_fim | hard | {
"lang": "rust",
"repo": "hacspec/hacspec",
"path": "/language/language-tests/enums.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the data field value.
///
/// # Examples
///
/// ```
/// use noodles_bam::record::data::{field::Value, Field};
/// use noodles_sam::record::data::field::Tag;
///
/// let field = Field::new(Tag::AlignmentHitCount, Value::Int32(1));
///
/// assert_eq!(... | code_fim | hard | {
"lang": "rust",
"repo": "luccasmmg/noodles",
"path": "/noodles-bam/src/record/data/field.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luccasmmg/noodles path: /noodles-bam/src/record/data/field.rs
//! BAM record data field and values.
pub mod value;
pub use self::value::Value;
use noodles_sam::record::data::field::Tag;
/// A BAM record data field.
#[derive(Clone, Debug, PartialEq)]
pub struct Field {
tag: Tag,
value... | code_fim | hard | {
"lang": "rust",
"repo": "luccasmmg/noodles",
"path": "/noodles-bam/src/record/data/field.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: j3-fortran/fortran_proposals path: /proposals/run-time_polymorphism/Examples/AppendixB/taylor.rs
// Rust implementation of the Taylor series example program based on
// subtyping given in Appendix B of the proposal "Improved run-time
// polymorphism for Fortran".
//
pub mod interfaces {
pu... | code_fim | hard | {
"lang": "rust",
"repo": "j3-fortran/fortran_proposals",
"path": "/proposals/run-time_polymorphism/Examples/AppendixB/taylor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use interfaces::IDeriv;
use interfaces::IHDeriv;
pub struct Taylor {
pub calc: Box<dyn IDeriv>
}
impl Taylor {
pub fn term1(&self) {
self.calc.deriv1();
}
pub fn evaluate(&self) {
println!("Evaluating Taylor series using");
self.term1... | code_fim | hard | {
"lang": "rust",
"repo": "j3-fortran/fortran_proposals",
"path": "/proposals/run-time_polymorphism/Examples/AppendixB/taylor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daniel-buse/advent_of_code_2019 path: /day02/src/main.rs
const OP_ADD: i32 = 1;
const OP_MUL: i32 = 2;
const OP_HALT: i32 = 99;
const PART2_PROGRAM_OUTPUT: i32 = 19_690_720;
fn run_program(memory: &mut [i32]) {
let mut i = 0;
loop {
let opcode = memory[i];
match opcode ... | code_fim | medium | {
"lang": "rust",
"repo": "daniel-buse/advent_of_code_2019",
"path": "/day02/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let input_str = include_str!("input.txt");
let input = input_str
.trim()
.split(',')
.map(str::parse)
.collect::<Result<Vec<i32>, _>>()
.unwrap();
part1(&input);
part2(&input);
}<|fim_prefix|>// repo: daniel-buse/advent_of_code_2019 path... | code_fim | hard | {
"lang": "rust",
"repo": "daniel-buse/advent_of_code_2019",
"path": "/day02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simonra/projectEuler path: /Rust/ProjectEulerProblem02.rs
fn main(){
let mut sum = 0u32;
let mut lastFib = 0u32;
let mut curentFib = 1u32;
let mut nextFib = 2u32;
loop {
if curentFib >= 4000000 {
println!("The sum is: {}", sum);
break;
... | code_fim | medium | {
"lang": "rust",
"repo": "simonra/projectEuler",
"path": "/Rust/ProjectEulerProblem02.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> lastFib = curentFib;
curentFib = nextFib;
nextFib = lastFib + curentFib;
}
}<|fim_prefix|>// repo: simonra/projectEuler path: /Rust/ProjectEulerProblem02.rs
fn main(){
let mut sum = 0u32;
let mut lastFib = 0u32;
let mut curentFib = 1u32;
let mut nextFib = 2u3... | code_fim | medium | {
"lang": "rust",
"repo": "simonra/projectEuler",
"path": "/Rust/ProjectEulerProblem02.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: justinmchase/verse-lang path: /src/runtime/ops/destructure.rs
use crate::ast::{Expression, Pattern};
use crate::runtime::{exec, transform, Context, RuntimeError, Scope, Value, Verse};
use std::rc::Rc;
pub fn destructure(
verse: Rc<Verse>,
context: Rc<Context>,
pattern: &Pattern,
express... | code_fim | medium | {
"lang": "rust",
"repo": "justinmchase/verse-lang",
"path": "/src/runtime/ops/destructure.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn destructure_succeeds_through_array() {
let v = Rc::new(Verse::default());
let c = v.create_context();
let _r = destructure(
v.clone(),
c.clone(),
&Pattern::Array(Some(Box::new(Pattern::Var(
String::from("x"),
Box::new(Pattern::Any),
)))),
... | code_fim | hard | {
"lang": "rust",
"repo": "justinmchase/verse-lang",
"path": "/src/runtime/ops/destructure.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let v = Rc::new(Verse::default());
let c = v.create_context();
let _r = destructure(
v.clone(),
c.clone(),
&Pattern::Var(String::from("x"), Box::new(Pattern::Any)),
&Expression::Int(7),
);
let v = c.get_var(String::from("x").to_string());
assert_eq!(v, Some... | code_fim | medium | {
"lang": "rust",
"repo": "justinmchase/verse-lang",
"path": "/src/runtime/ops/destructure.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> twice(value, |value_ref, item| invoke2(value_ref, item));
//~^ ERROR the parameter type `T` may not live long enough
}
fn invoke2<'a, T, U>(a: &T, b: Cell<&'a Option<U>>)
where
T: 'a,
{
}
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/nll/ty-outlives/p... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/nll/ty-outlives/projection-implied-bounds.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/nll/ty-outlives/projection-implied-bounds.rs
// Test that we can deduce when projections like `T::Item` outlive the
// function body. Test that this does not imply that `T: 'a` holds.
// compile-flags:-Zborrowck=mir -Zverbose
use std::cell::Ce... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/nll/ty-outlives/projection-implied-bounds.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gitter-badger/wezterm path: /term/src/line.rs
use hyperlink::Rule;
use std::ops::Range;
use std::str;
use super::*;
#[derive(Debug, Clone, Eq, PartialEq)]
enum ImplicitHyperlinks {
DontKnow,
HasNone,
HasSome,
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Line {
pub cells... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/wezterm",
"path": "/term/src/line.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (cell_idx, c) in self.cells.iter().enumerate() {
let cell_str = c.str();
last_cluster = match last_cluster.take() {
None => {
// Start new cluster
Some(CellCluster::new(c.attrs.clone(), cell_str, cell_idx))
... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/wezterm",
"path": "/term/src/line.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use std::fs::{self, File};
use std::io;
#[test]
fn test_send_recv() -> io::Result<()> {
let mut wrt = File::create("foo.txt")?;
send_message(&mut wrt, "hello")?;
let mut rd = File::open("foo.txt")?;
let msg = recv_... | code_fim | hard | {
"lang": "rust",
"repo": "jkabc123/ruraft",
"path": "/raftio/src/transport.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jkabc123/ruraft path: /raftio/src/transport.rs
use std::io::{self, prelude::*};
/// Send a message with an arbitrary length
///
/// # Examples
///
/// ```
/// # use ::raftio::*;
/// use std::fs::{self, File};
/// let mut sock = File::create("foo.txt").unwrap();
/// send_message(&mut sock, "hell... | code_fim | hard | {
"lang": "rust",
"repo": "jkabc123/ruraft",
"path": "/raftio/src/transport.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut wrt = File::create("foo.txt")?;
send_message(&mut wrt, "hello")?;
let mut rd = File::open("foo.txt")?;
let msg = recv_message(&mut rd).unwrap();
assert_eq!(msg, "hello");
fs::remove_file("foo.txt")?;
Ok(())
}
}<|fim_prefix|>// repo: jkab... | code_fim | hard | {
"lang": "rust",
"repo": "jkabc123/ruraft",
"path": "/raftio/src/transport.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Recycler {
gc: Arc::new(Mutex::new(vec![])),
}
}
}
impl<T: Default> Clone for Recycler<T> {
fn clone(&self) -> Recycler<T> {
Recycler {
gc: self.gc.clone(),
}
}
}
impl<T: Default> Recycler<T> {
pub fn allocate(&self) -> Arc<RwLock<T... | code_fim | hard | {
"lang": "rust",
"repo": "sakridge/solana",
"path": "/src/packet.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sakridge/solana path: /src/packet.rs
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use result::{Error, Result};
use std::collections::VecDeque;
use std::fmt;
use std::io;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket};
use std::sync::{Arc, Mutex, RwLock};
pub ty... | code_fim | hard | {
"lang": "rust",
"repo": "sakridge/solana",
"path": "/src/packet.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lagudomeze/enumx path: /cex/src/test/named.rs
use super::*;
use enumx_derive::Exchange;
#[ derive( Exchange, Debug )]
enum ReadU32Error {
IO( std::io::Error ),
Parse( std::num::ParseIntError ),
}
fn read_u32( filename: &'static str )
-> Result<u32, Cex<ReadU32Error>>
{
use std... | code_fim | hard | {
"lang": "rust",
"repo": "lagudomeze/enumx",
"path": "/cex/src/test/named.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(
a_mul_b_eq_c( "src/test/not_num", "src/test/7", "src/test/21"
).map_err( |cex|
if let AMulBEqCError::Parse(_) = cex.error { true } else { false }
).unwrap_err() );
assert!(
a_mul_b_eq_c( "src/test/3", "src/test/no_file", "src/test/21"
)... | code_fim | hard | {
"lang": "rust",
"repo": "lagudomeze/enumx",
"path": "/cex/src/test/named.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tower = state.mut_space(&self.position).mut_tower();
if tower.dome().is_some() {
Err(SantoriniError::InvalidBuild(self.position))
} else {
match tower.level() {
Level::Three => {
tower.mut_dome().replace(Dome);
... | code_fim | hard | {
"lang": "rust",
"repo": "mingyli/santorini",
"path": "/santorini-common/src/command.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Command for BuildCommand {
fn execute(&self, state: &mut State) -> Result<(), SantoriniError> {
let tower = state.mut_space(&self.position).mut_tower();
if tower.dome().is_some() {
Err(SantoriniError::InvalidBuild(self.position))
} else {
match towe... | code_fim | hard | {
"lang": "rust",
"repo": "mingyli/santorini",
"path": "/santorini-common/src/command.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mingyli/santorini path: /santorini-common/src/command.rs
use crate::{
error::SantoriniError,
objects::{
state::State,
tower::{Dome, Level},
},
position::Position,
};
pub trait Command {
fn execute(&self, state: &mut State) -> Result<(), SantoriniError>;
f... | code_fim | hard | {
"lang": "rust",
"repo": "mingyli/santorini",
"path": "/santorini-common/src/command.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "multitask")]
#[doc(cfg(feature = "multitask"))]
pub use self::mutex::{Mutex, MutexGuard};
#[cfg(not(feature = "multitask"))]
#[doc(cfg(not(feature = "multitask")))]
pub use spinlock::{SpinRaw as Mutex, SpinRawGuard as MutexGuard}; // never used in IRQ context<|fim_prefix|>// repo: rcore-... | code_fim | medium | {
"lang": "rust",
"repo": "rcore-os/arceos",
"path": "/ulib/axstd/src/sync/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcore-os/arceos path: /ulib/axstd/src/sync/mod.rs
//! Useful synchronization primitives.
#[doc(no_inline)]
pub use core::sync::atomic;
#[cfg(feature = "alloc")]
#[doc(no_inline)]
pub use alloc::sync::{Arc, Weak};
#[cfg(feature = "multitask")]
mod mutex;
<|fim_suffix|>#[cfg(not(feature = "mul... | code_fim | medium | {
"lang": "rust",
"repo": "rcore-os/arceos",
"path": "/ulib/axstd/src/sync/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mcaveniathor/arx-kw path: /src/util.rs
use siphasher::sip128::{SipHasher24,Hasher128};
use std::hash::Hasher;
use crate::{AuthTag};
/// Hashes a message using SipHash2-4 with a 128-bit output
///
///Creates a Sip-2-4 instance keyed with the contents of `key` and set to output 128 bits of data
/... | code_fim | hard | {
"lang": "rust",
"repo": "mcaveniathor/arx-kw",
"path": "/src/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Creates an `XChaCha8` stream (8 rounds with a 24-byte nonce) and the counter set to 0
/// Initialized like an `XChaCha20` but with 8 rounds for both the intially generated ChaCha block and
/// the stream constructed with it.
#[must_use] pub fn new(key: &[u8; 32], nonce: &[u8; 24]) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "mcaveniathor/arx-kw",
"path": "/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_queries<E>(kp: &KeyPairAssembly<E>, domain_size: usize) -> (usize, usize)
where
E: Engine
{
let g1_query: usize = {
let h_query: _ = domain_size;
let icl_query: _ = kp.num_inputs + kp.num_aux;
let a_query: _ = kp.num_inputs + kp.num_aux;
let b_query: _ = kp.... | code_fim | hard | {
"lang": "rust",
"repo": "s-i-l-k-e/librustzcash",
"path": "/bellman/src/groth16/generator/assembly/windows.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: s-i-l-k-e/librustzcash path: /bellman/src/groth16/generator/assembly/windows.rs
use group::Wnaf;
use pairing::Engine;
use crate::{domain, arith};
use domain::Domain;
use arith::Group;
use super::{KeyPairAssembly, ParameterAssembly};
pub struct WindowTables<E>
where
E: Engine
{
g1: Wna... | code_fim | hard | {
"lang": "rust",
"repo": "s-i-l-k-e/librustzcash",
"path": "/bellman/src/groth16/generator/assembly/windows.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl Tr1 for ::S {}
impl Tr2 for ::S {}
}
mod unused {
use m::Tr1 as _; //~ WARN unused import
use S as _; //~ WARN unused import
extern crate core as _; // OK
}
mod outer {
mod middle {
pub use m::Tr1 as _;
pub use m::Tr2 as _; // OK, no name conflict
str... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/underscore-imports/basic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/underscore-imports/basic.rs
// build-pass (FIXME(62277): could be check-pass?)
// aux-build:underscore-imports.rs
#![warn(unused_imports, unused_extern_crates)]
#[macro_use]
extern crate underscore_imports as _;
<|fim_suffix|> }
pub tr... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/underscore-imports/basic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /yukicoder/1108.rs
use std::io::Read;
fn read<T: std::str::FromStr>() -> T {
<|fim_suffix|> let n: i32 = read();
let h: i32 = read();
let t: Vec<i32> = (0..n).map(|_| read()).collect();
println!(
"{}",
t.iter()
.map(... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/yukicoder/1108.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n: i32 = read();
let h: i32 = read();
let t: Vec<i32> = (0..n).map(|_| read()).collect();
println!(
"{}",
t.iter()
.map(|&x| (x + h).to_string())
.collect::<Vec<_>>()
.join(" ")
);
}<|fim_prefix|>// repo: ia7ck/competitive-program... | code_fim | medium | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/yukicoder/1108.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl LogProcessor for StdoutOutput {
fn process_line(&self, log_line: &RequestLogLine) -> Result<()> {
self.writer
.from_writer(std::io::stdout())
.serialize(log_line)?;
Ok(())
}
}<|fim_prefix|>// repo: jaysonsantos/elb-logs-to-cloudwatch path: /src/output/... | code_fim | medium | {
"lang": "rust",
"repo": "jaysonsantos/elb-logs-to-cloudwatch",
"path": "/src/output/stdout.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jaysonsantos/elb-logs-to-cloudwatch path: /src/output/stdout.rs
use anyhow::Result;
use serde::{Deserialize, Serialize};
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)]
pub struct StdoutOutput {
#[serde(skip, default = "crate::log_processing::csv_writer_builder")]
writer: csv::Wr... | code_fim | medium | {
"lang": "rust",
"repo": "jaysonsantos/elb-logs-to-cloudwatch",
"path": "/src/output/stdout.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mut self: Pin<&mut Self>,
act: &mut A,
ctx: &mut A::Context,
task: &mut Context<'_>,
) -> Poll<Self::Output> {
let mut this = self.as_mut().project();
loop {
match ready!(this.stream.as_mut().poll_next(act, ctx, task)) {
Some(... | code_fim | hard | {
"lang": "rust",
"repo": "actix/actix",
"path": "/actix/src/fut/stream/collect.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: actix/actix path: /actix/src/fut/stream/collect.rs
use std::{
mem,
pin::Pin,
task::{Context, Poll},
};
use futures_core::ready;
use pin_project_lite::pin_project;
use super::ActorStream;
use crate::{actor::Actor, fut::future::ActorFuture};
pin_project! {
/// Future for the [`c... | code_fim | medium | {
"lang": "rust",
"repo": "actix/actix",
"path": "/actix/src/fut/stream/collect.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let numbers = vec!["Vasya", "Petya", "Vlad", "Vlad", "Vlad"];
let mut counts = HashMap::<_, u64>::new();
for number in &numbers {
*counts.entry(*number).or_default() += 1;
}
println!("Names Counts: {:?}", counts);
let a = Ratio::new_raw(11, 10);
let b = Ratio::new_raw(... | code_fim | hard | {
"lang": "rust",
"repo": "qbit-org-ua/2020-practice-rust",
"path": "/contest-1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qbit-org-ua/2020-practice-rust path: /contest-1/src/main.rs
use std::collections::{HashMap, HashSet};
use std::convert::TryInto;
use num_rational::Ratio;
fn main() {}
fn _old4() {
// фиксированный массив
let four_ints: [i32; 4] = [1, 2, 3, 4];
//let four_ints: [i32; 30] = [0; 30];... | code_fim | hard | {
"lang": "rust",
"repo": "qbit-org-ua/2020-practice-rust",
"path": "/contest-1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hioki/gatekeeper path: /src/session.rs
ync::{Arc, Mutex};
use std::thread;
use log::*;
use crate::auth_service::AuthService;
use crate::byte_stream::ByteStream;
use crate::connector::Connector;
use crate::model::dao::*;
use crate::model::model::*;
use crate::model::{Error, ErrorKind};
use crat... | code_fim | hard | {
"lang": "rust",
"repo": "hioki/gatekeeper",
"path": "/src/session.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hioki/gatekeeper path: /src/session.rs
:ops::{Deref, DerefMut};
use std::sync::mpsc::{self, SyncSender};
use std::sync::{Arc, Mutex};
use std::thread;
use log::*;
use crate::auth_service::AuthService;
use crate::byte_stream::ByteStream;
use crate::connector::Connector;
use crate::model::dao::*... | code_fim | hard | {
"lang": "rust",
"repo": "hioki/gatekeeper",
"path": "/src/session.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn connect_not_allowed() {
use crate::auth_service::NoAuthService;
let version: ProtocolVersion = 5.into();
let connect_to = Address::from_str("192.168.0.1:5123").unwrap();
let (tx, _rx) = mpsc::channel::<ServerCommand<()>>();
let (session, _) = Sess... | code_fim | hard | {
"lang": "rust",
"repo": "hioki/gatekeeper",
"path": "/src/session.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GanidhuAbey/rEngine path: /r_engine/src/draw.rs
use crate::render;
use std::ffi::CString;
pub fn clear() {
unsafe {
gl::Clear(gl::COLOR_BUFFER_BIT);
};
}
pub fn rectangle(w: f32, h: f32, x: f32, y: f32) {
let vert_shader = render::Shader::from_vert_source(&CString::new(inclu... | code_fim | hard | {
"lang": "rust",
"repo": "GanidhuAbey/rEngine",
"path": "/r_engine/src/draw.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
gl::BindVertexArray(vao);
gl::DrawArrays(
gl::TRIANGLES,
0,
3,
);
}
}
pub fn triangle(color: [f32; 3]) {
let vert_shader = render::Shader::from_vert_source(&CString::new(include_str!("triangle.vert")).unwrap()).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "GanidhuAbey/rEngine",
"path": "/r_engine/src/draw.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> gl::BindBuffer(gl::ARRAY_BUFFER, 0);
gl::BindVertexArray(0);
}
shader_program.set_used();
unsafe {
gl::BindVertexArray(vao);
gl::DrawArrays(
gl::TRIANGLES,
0,
3,
);
}
}
pub fn triangle(color: [f32; 3]) {
let... | code_fim | hard | {
"lang": "rust",
"repo": "GanidhuAbey/rEngine",
"path": "/r_engine/src/draw.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mitre/pact-reference path: /rust/pact_matching/src/models/xml_utils.rs
//! Collection of utilities for working with XML
<|fim_suffix|>/// Parses a vector of bytes into a XML document
pub fn parse_bytes(bytes: &[u8]) -> Result<Package, String> {
let string = str::from_utf8(bytes).map_err(|_| f... | code_fim | easy | {
"lang": "rust",
"repo": "mitre/pact-reference",
"path": "/rust/pact_matching/src/models/xml_utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Parses a vector of bytes into a XML document
pub fn parse_bytes(bytes: &[u8]) -> Result<Package, String> {
let string = str::from_utf8(bytes).map_err(|_| format!("{:?}", bytes))?;
parser::parse(string).map_err(|e| format!("{:?}", e))
}<|fim_prefix|>// repo: mitre/pact-reference path: /rust/pact_m... | code_fim | easy | {
"lang": "rust",
"repo": "mitre/pact-reference",
"path": "/rust/pact_matching/src/models/xml_utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for Protocol {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Protocol::UDP => write!(f, "UDP"),
Protocol::TCP => write!(f, "TCP"),
}
}
}
#[derive(Debug, Serialize, PartialEq)]
pub enum State {
New,
Destroy,
... | code_fim | hard | {
"lang": "rust",
"repo": "awesome-security/ZeroTrust-Track",
"path": "/src/enums/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: awesome-security/ZeroTrust-Track path: /src/enums/mod.rs
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*... | code_fim | medium | {
"lang": "rust",
"repo": "awesome-security/ZeroTrust-Track",
"path": "/src/enums/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize)]
pub enum Protocol {
UDP,
TCP,
}
impl fmt::Display for Protocol {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Protocol::UDP => write!(f, "UDP"),
Protocol::TCP => write!(f, "TCP"),
}
}
}
#[derive(D... | code_fim | hard | {
"lang": "rust",
"repo": "awesome-security/ZeroTrust-Track",
"path": "/src/enums/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let seconds = unsafe { atoi(ss.as_ptr() as *const fk_std::c_char) };
unsafe { printf("Shutting down...\n".as_ptr() as *const fk_std::c_char); }
unsafe { shutdown(seconds) }
}
pub fn shutdown_main(arg: &str) -> i32 {
if asku::asku_main() == true {
start_shutdown(arg);
} return ... | code_fim | easy | {
"lang": "rust",
"repo": "NathanMcMillan54/builtin_commands",
"path": "/shutdown/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NathanMcMillan54/builtin_commands path: /shutdown/src/lib.rs
#![no_std]
extern crate fk_std;
use fk_std::libc::{atoi, printf};
extern crate asku;
extern "C" {
fn shutdown(s: i32) -> !;
}
<|fim_suffix|>pub fn shutdown_main(arg: &str) -> i32 {
if asku::asku_main() == true {
star... | code_fim | hard | {
"lang": "rust",
"repo": "NathanMcMillan54/builtin_commands",
"path": "/shutdown/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl StorageConfig for CaldavConfig {
fn get_collection(&self) -> Option<&str> {
self.dav.get_collection()
}
}
impl ConfigurableStorage for CaldavStorage {
type Config = CaldavConfig;
fn from_config(_config: Self::Config) -> Fallible<Self> {
unimplemented!();
}
f... | code_fim | hard | {
"lang": "rust",
"repo": "erictapen/vdirsyncer",
"path": "/rust/src/storage/dav/caldav.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn from_config(_config: Self::Config) -> Fallible<Self> {
unimplemented!();
}
fn discover(config: Self::Config) -> Fallible<Box<Iterator<Item = Self::Config>>> {
let mut dav = DavClient::new(&config.dav.url, config.dav.http.clone());
let item_types = config.item_types... | code_fim | hard | {
"lang": "rust",
"repo": "erictapen/vdirsyncer",
"path": "/rust/src/storage/dav/caldav.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erictapen/vdirsyncer path: /rust/src/storage/dav/caldav.rs
use chrono;
use reqwest::header::{ContentType, Headers};
use super::dav_methods::*;
use super::parser;
use super::{DavClient, DavConfig, StorageType, XmlTag};
use storage::http::HttpConfig;
use storage::utils::generate_href;
use storag... | code_fim | hard | {
"lang": "rust",
"repo": "erictapen/vdirsyncer",
"path": "/rust/src/storage/dav/caldav.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn add_in_different_order2() {
use BinarySearchTree;
let mut bst1 = BinarySearchTree::new();
bst1.add(8);
bst1.add(5);
bst1.add(10);
bst1.add(5);
bst1.add(3);
bst1.add(5);
bst1.add(6);
bst1.add(8);
bst1.add(9);
bst1.add(15);
let mut bst2 = Bina... | code_fim | hard | {
"lang": "rust",
"repo": "laysakura/data-structures-and-algorithms-rs",
"path": "/src/binary_search_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn get_all_sorted() {
let mut bst = BinarySearchTree::new();
bst.add(8);
bst.add(5);
bst.add(10);
bst.add(5);
bst.add(3);
bst.add(5);
bst.add(6);
bst.add(8);
bst.add(9);
bst.add(15);
assert_eq!(
bst.get_all_sorted(),
vec![&3, &5, &5,... | code_fim | hard | {
"lang": "rust",
"repo": "laysakura/data-structures-and-algorithms-rs",
"path": "/src/binary_search_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laysakura/data-structures-and-algorithms-rs path: /src/binary_search_tree.rs
/// 二分探索木。
/// あるノードと等しい値は、必ず左側の子ノード以下に入ることとする。
///
/// ```text
/// 8
/// __/ \__
/// / \
/// 5 10
/// / \ / \
/// 5 6 9 15
/// / \
/// 3 8
/// \
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "laysakura/data-structures-and-algorithms-rs",
"path": "/src/binary_search_tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[allow(non_snake_case)]
pub fn updatesEnabled(&self) -> bool {
return unsafe { glue::_qrust_qwidget_m_updatesEnabled(self.0) } != 0;
}
#[allow(non_snake_case)]
pub fn minimumWidth(&self) -> i32 {
return unsafe { glue::_qrust_qwidget_m_minimumWidth(self.0) } as i32;
}
#[allow(non_snake_case)]... | code_fim | hard | {
"lang": "rust",
"repo": "vojtechkral/qrust",
"path": "/qrust-widgets/src/qwidget.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vojtechkral/qrust path: /qrust-widgets/src/qwidget.rs
s(&self) -> () {
return unsafe { glue::_qrust_qwidget_m_clearFocus(self.0) };
}
#[allow(non_snake_case)]
pub fn isFullScreen(&self) -> bool {
return unsafe { glue::_qrust_qwidget_m_isFullScreen(self.0) } != 0;
}
#[allow(non_snake_c... | code_fim | hard | {
"lang": "rust",
"repo": "vojtechkral/qrust",
"path": "/qrust-widgets/src/qwidget.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// **Unimplemented:** `QWidget::sizeIncrement()`
#[allow(non_snake_case)]
pub fn sizeIncrement(&self) -> ! {
unimplemented!();
}
/// **Unimplemented:** `QWidget::setInputMethodHints(hints)`
#[allow(non_snake_case)]
pub fn setInputMethodHints(&self) -> ! {
unimplemented!();
}
/// **Unimplem... | code_fim | hard | {
"lang": "rust",
"repo": "vojtechkral/qrust",
"path": "/qrust-widgets/src/qwidget.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rupertgatti/thoth path: /src/models/language.rs
use uuid::Uuid;
use crate::schema::language;
#[derive(Debug, PartialEq, DbEnum, juniper::GraphQLEnum)]
#[DieselType = "Language_relation"]
pub enum LanguageRelation {
Original,
#[db_rename = "translated-from"]
TranslatedFrom,
#[db... | code_fim | hard | {
"lang": "rust",
"repo": "rupertgatti/thoth",
"path": "/src/models/language.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Peo,
Per,
Phi,
Phn,
Pli,
Pol,
Pon,
Por,
Pra,
Pro,
Pus,
Qaa,
Que,
Raj,
Rap,
Rar,
Roa,
Roh,
Rom,
Rum,
Run,
Rup,
Rus,
Sad,
Sag,
Sah,
Sai,
Sal,
Sam,
San,
Sas,
Sat,
Scn,
Sco,
... | code_fim | hard | {
"lang": "rust",
"repo": "rupertgatti/thoth",
"path": "/src/models/language.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Microsvuln/IRL path: /src/lang/print.rs
use std::cell::RefCell;
use std::io::{Error, Write};
use std::ops::Deref;
use crate::lang::func::{BlockRef, Fn};
use crate::lang::inst::{Inst, InstRef, PhiSrc};
use crate::lang::Program;
use crate::lang::value::{GlobalVar, Symbol, Type, Typed, Value};
pu... | code_fim | hard | {
"lang": "rust",
"repo": "Microsvuln/IRL",
"path": "/src/lang/print.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn print_instr(&mut self, instr: &InstRef) -> Result<(), Error> {
let s = match instr.deref() {
Inst::Mov { src, dst } =>
format!("{} <- mov {} {}", fmt_val!(dst), fmt_ty!(dst), fmt_val!(src)),
Inst::Un { op, opd, dst } =>
format!("{} <- ... | code_fim | hard | {
"lang": "rust",
"repo": "Microsvuln/IRL",
"path": "/src/lang/print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn fmt_opd_list(&self, opd: &Vec<RefCell<Value>>) -> String {
let vec: Vec<String> = opd.iter().map(|v| v.borrow().to_string()).collect();
vec.join(", ")
}
fn fmt_phi_list(&self, list: &Vec<PhiSrc>) -> String {
let vec: Vec<String> = list.iter()
.map(|(b, v... | code_fim | hard | {
"lang": "rust",
"repo": "Microsvuln/IRL",
"path": "/src/lang/print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dannysauer/gary path: /gary/src/cluster_api.rs
use gary_zmq::cluster_api::*;
<|fim_suffix|>pub fn start(m: Arc<Mutex<HashMap<String, DateTime<Utc>>>>) {
let m = ZmqClusterApi::new(m);
m.run();
println!("Cluster Api Running");
}<|fim_middle|>use chrono::{DateTime, Utc};
use std::coll... | code_fim | medium | {
"lang": "rust",
"repo": "dannysauer/gary",
"path": "/gary/src/cluster_api.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn start(m: Arc<Mutex<HashMap<String, DateTime<Utc>>>>) {
let m = ZmqClusterApi::new(m);
m.run();
println!("Cluster Api Running");
}<|fim_prefix|>// repo: dannysauer/gary path: /gary/src/cluster_api.rs
use gary_zmq::cluster_api::*;
<|fim_middle|>use chrono::{DateTime, Utc};
use std::coll... | code_fim | medium | {
"lang": "rust",
"repo": "dannysauer/gary",
"path": "/gary/src/cluster_api.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let choices = AgentNameAndVersionSet::a_sensible_set_of_choices_for_an_international_website_in_multiple_languages(&can_i_use, maximum_release_age_from_can_i_use_database_last_updated, minimum_usage_threshold, ®ional_usages);
(can_i_use, choices)
}<|fim_prefix|>// repo: lemonrock/caniuse-serde pat... | code_fim | hard | {
"lang": "rust",
"repo": "lemonrock/caniuse-serde",
"path": "/src/sensible_choices.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lemonrock/caniuse-serde path: /src/sensible_choices.rs
// This file is part of caniuse-serde. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/caniuse-serde/master/COPYRIGHT. No part ... | code_fim | hard | {
"lang": "rust",
"repo": "lemonrock/caniuse-serde",
"path": "/src/sensible_choices.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: warp-tech/warpgate path: /warpgate-core/src/recordings/traffic.rs
use std::net::Ipv4Addr;
use anyhow::Result;
use bytes::Bytes;
use packet::Builder;
use rand::Rng;
use tokio::time::Instant;
use tracing::*;
use warpgate_db_entities::Recording::RecordingKind;
use super::writer::RecordingWriter;
... | code_fim | hard | {
"lang": "rust",
"repo": "warp-tech/warpgate",
"path": "/warpgate-core/src/recordings/traffic.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok((
self.tcp_packet_tx(|b| {
Ok(b.sequence(seq_tx)?
.flags(packet::tcp::Flags::SYN)?
.build()?
.into())
})?,
self.tcp_packet_rx(|b| {
Ok(b.sequence(seq_rx)?
... | code_fim | hard | {
"lang": "rust",
"repo": "warp-tech/warpgate",
"path": "/warpgate-core/src/recordings/traffic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bikeshedder/advent-of-code path: /2019/src/bin/01b.rs
const INPUT: &str = include_str!("../input/01.txt");
fn fuel(mut mass: usize) -> usize {
let mut fuel = 0;
while mass > 0 {
mass = std::cmp::max((mass as isize / 3) - 2, 0) as usize;
fuel += mass;
}
fuel
}
<|... | code_fim | easy | {
"lang": "rust",
"repo": "bikeshedder/advent-of-code",
"path": "/2019/src/bin/01b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut fuel = 0;
while mass > 0 {
mass = std::cmp::max((mass as isize / 3) - 2, 0) as usize;
fuel += mass;
}
fuel
}
fn main() {
let output: usize = INPUT
.trim()
.split_whitespace()
.map(|line| line.parse::<usize>().unwrap())
.map(fuel)... | code_fim | easy | {
"lang": "rust",
"repo": "bikeshedder/advent-of-code",
"path": "/2019/src/bin/01b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
remaining_allocations
before
import
.
"
)
;
self
.
allocations_remains
-
=
1
;
let
atom_mask
=
if
host_visible_non_coherent
(
props
)
{
self
.
non_coherent_atom_mask
}
else
{
0
}
;
heap
.
alloc
(
size
)
;
MemoryBlock
:
:
new
(
memory_type
props
offset
size
atom_mask
MemoryBlockFlavor
:
:
Dedicated
{
memo... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/gpu-alloc/src/allocator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/gpu-alloc/src/allocator.rs
hold
:
u64
max_memory_allocation_size
:
u64
memory_for_usage
:
MemoryForUsage
memory_types
:
Box
<
[
MemoryType
]
>
memory_heaps
:
Box
<
[
Heap
]
>
allocations_remains
:
u32
non_coherent_atom_mask
:
u64
starting_free_... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/gpu-alloc/src/allocator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>m_mask
other
=
>
other
}
;
let
final_free_list_chunk
=
match
align_down
(
self
.
final_free_list_chunk
.
max
(
self
.
starting_free_list_chunk
)
.
max
(
self
.
transient_dedicated_threshold
)
.
min
(
heap
.
size
(
)
/
32
)
atom_mask
)
{
0
=
>
atom_mask
other
=
>
other
}
;
slot
.
get_or_insert
(
FreeListAl... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/gpu-alloc/src/allocator.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.