text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> pub fn as_bytes(&self) -> &[u8] {
&self.bytes[..self.data_size]
}
pub fn as_bytes_mut(&mut self) -> &mut [u8] {
&mut self.bytes[..self.data_size]
}
/// 永続化用のバイト列を返す.
fn as_external_bytes(&self) -> &[u8] {
self.bytes.as_ref()
}
fn write_to<W: Write... | code_fim | hard | {
"lang": "rust",
"repo": "sile/cannyls",
"path": "/src/storage/data_region.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let offset = portion.start.as_u64() * u64::from(self.block_size.as_u16());
let size = portion.len as usize * self.block_size.as_u16() as usize;
(offset, size)
}
/// `size`分のデータをカバーするのに必要なブロック数.
fn block_count(&self, size: u32) -> u32 {
(size + u32::from(self.bl... | code_fim | hard | {
"lang": "rust",
"repo": "sile/cannyls",
"path": "/src/storage/data_region.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: naftulikay/nfty path: /src/project/templates/python.rs
use askama::Template;
use std::collections::BTreeSet;
use std::fs;
use std::io::Result;
use std::io::Write;
use std::path::Path;
#[derive(Default, Template, WritableTemplate)]
#[template(path = "python/requirements.txt.j2")]
pub struct Pyt... | code_fim | hard | {
"lang": "rust",
"repo": "naftulikay/nfty",
"path": "/src/project/templates/python.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // FIXME this does strip out empty lines and comments, but otherwise this would be a lot
// harder to do.
fs::read_to_string(path)?
.lines()
.map(|l| l.trim())
.filter(|l| l.len() > 0)
.filter(|l| !l.starts_with("#"))
.for... | code_fim | medium | {
"lang": "rust",
"repo": "naftulikay/nfty",
"path": "/src/project/templates/python.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new() -> Self {
Self::default()
}
pub fn requirement(mut self, req: String) -> Self {
self.requirements.insert(req);
self
}
}<|fim_prefix|>// repo: naftulikay/nfty path: /src/project/templates/python.rs
use askama::Template;
use std::collections::BTreeSet;... | code_fim | medium | {
"lang": "rust",
"repo": "naftulikay/nfty",
"path": "/src/project/templates/python.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn main() {
let args: Vec<String> = env::args().collect();
if let Err(e) = parse_args(args) {
eprintln!("Error: {}", e);
}
}<|fim_prefix|>// repo: ewarchul/ocean path: /src/main.rs
#![allow(clippy::pedantic)]
mod cache;
mod commands;
mod common;
mod compiler;
mod edito... | code_fim | hard | {
"lang": "rust",
"repo": "ewarchul/ocean",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ewarchul/ocean path: /src/main.rs
#![allow(clippy::pedantic)]
mod cache;
mod commands;
mod common;
mod compiler;
mod editors;
mod language;
mod platform;
mod project;
use commands::Commands;
use common::StrRet;
use std::env;
fn parse_args(mut args: Vec<String>) -> Result<(), StrRet> {
<|fim_s... | code_fim | hard | {
"lang": "rust",
"repo": "ewarchul/ocean",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: juntyr/necsim-rust path: /rustcoalescence/src/args/utils/parse.rs
use anyhow::{Context, Result};
use ron::{extensions::Extensions, ser::PrettyConfig, Options};
use serde::{Deserialize, Serialize};
use serde_state::DeserializeState;
#[allow(clippy::module_name_repetitions)]
pub fn try_parse<'de,... | code_fim | hard | {
"lang": "rust",
"repo": "juntyr/necsim-rust",
"path": "/rustcoalescence/src/args/utils/parse.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match deserializer(de) {
Ok(args) => Ok(args),
Err(err) => {
let path = track.path();
let err = de_ron.span_error(err);
Err(anyhow::anyhow!(
"{}{}{}{} @ ({}):\n{}",
subcommand,
if path.iter().count() >... | code_fim | hard | {
"lang": "rust",
"repo": "juntyr/necsim-rust",
"path": "/rustcoalescence/src/args/utils/parse.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn paint(&self, window_width: u32, window_height: u32) {
unsafe {
let (r, g, b, a) = self.background_color.to_float();
gl::Viewport(0, 0, window_width as i32, window_height as i32);
gl::MatrixMode(gl::PROJECTION);
gl::LoadIdentity();
... | code_fim | hard | {
"lang": "rust",
"repo": "wibbe/organizer",
"path": "/src/ui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let glyph = font::get_glyph(cell.ch).unwrap();
font::draw_glyph(x, y, glyph);
}
}
/*
for ch in "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzÅåÄäÖö0123456789".chars() {
let glyph = font::get_glyph(ch).u... | code_fim | hard | {
"lang": "rust",
"repo": "wibbe/organizer",
"path": "/src/ui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wibbe/organizer path: /src/ui.rs
use std::default::Default;
use std::collections::HashMap;
use ::gl;
use ::font;
#[derive(Copy, Clone, Debug)]
pub struct Color {
r: u8,
g: u8,
b: u8,
a: u8,
}
impl Default for Color {
fn default() -> Color {
Color { r: 0, g: 0, b:... | code_fim | hard | {
"lang": "rust",
"repo": "wibbe/organizer",
"path": "/src/ui.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VictorElHajj/Advent-of-code-2020 path: /src/day16.rs
use std::cell::Cell;
#[derive(Debug)]
pub struct Rule {
pos: Cell<u16>,
min1: u16,
max1: u16,
min2: u16,
max2: u16,
}
impl Rule {
fn from_str(input: &str) -> Rule {
let mut iter = input.bytes();
let mi... | code_fim | hard | {
"lang": "rust",
"repo": "VictorElHajj/Advent-of-code-2020",
"path": "/src/day16.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day16, part1)]
pub fn part1((rules, _, nearby_tickets): &(Vec<Rule>, Ticket, Vec<Ticket>)) -> u16 {
let mut invalid_sum = 0;
for ticket in nearby_tickets {
for value in ticket {
if !rules.iter().any(|rule| rule.is_valid(value)) {
invalid_sum += value;
... | code_fim | hard | {
"lang": "rust",
"repo": "VictorElHajj/Advent-of-code-2020",
"path": "/src/day16.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day16, part2)]
pub fn part2((rules, your_ticket, nearby_tickets): &(Vec<Rule>, Ticket, Vec<Ticket>)) -> u64 {
let len = your_ticket.len();
// begin by repeating part in in iterator style to filter out invalid tickets
let valid_tickets: Vec<Ticket> = nearby_tickets
.iter()
... | code_fim | hard | {
"lang": "rust",
"repo": "VictorElHajj/Advent-of-code-2020",
"path": "/src/day16.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) type ParticleForceGeneratorOpsContainer = Vec<Box<dyn ParticleForceGeneratorOps>>;<|fim_prefix|>// repo: bumzack/godot path: /game-physics/src/force/particle_force_types.rs
use crate::force::particle_force_generator::ParticleForceGeneratorOps;
<|fim_middle|>pub(crate) type ParticleIdx = usize... | code_fim | medium | {
"lang": "rust",
"repo": "bumzack/godot",
"path": "/game-physics/src/force/particle_force_types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bumzack/godot path: /game-physics/src/force/particle_force_types.rs
use crate::force::particle_force_generator::ParticleForceGeneratorOps;
<|fim_suffix|>pub(crate) type ParticleForceGeneratorOpsContainer = Vec<Box<dyn ParticleForceGeneratorOps>>;<|fim_middle|>pub(crate) type ParticleIdx = usize... | code_fim | medium | {
"lang": "rust",
"repo": "bumzack/godot",
"path": "/game-physics/src/force/particle_force_types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stepfunc/rustls path: /rustls/src/kx.rs
use crate::msgs::enums::NamedGroup;
/// The result of a key exchange. This has our public key,
/// and the agreed shared secret (also known as the "premaster secret"
/// in TLS1.0-era protocols, and "Z" in TLS1.3).
pub(crate) struct KeyExchangeResult {
... | code_fim | hard | {
"lang": "rust",
"repo": "stepfunc/rustls",
"path": "/rustls/src/kx.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Return the group being used.
pub(crate) fn group(&self) -> NamedGroup {
self.skxg.name
}
/// Completes the key exchange, given the peer's public key. The shared
/// secret is returned as a KeyExchangeResult.
pub(crate) fn complete(self, peer: &[u8]) -> Option<KeyExcha... | code_fim | hard | {
"lang": "rust",
"repo": "stepfunc/rustls",
"path": "/rustls/src/kx.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WRansohoff/svd path: /src/svd/usage.rs
#[cfg(feature = "unproven")]
use std::collections::HashMap;
use elementext::ElementExt;
use xmltree::Element;
#[cfg(feature = "unproven")]
use encode::Encode;
use error::*;
use types::Parse;
#[cfg(feature = "serde_svd")]
use super::serde::{ Deserialize, ... | code_fim | hard | {
"lang": "rust",
"repo": "WRansohoff/svd",
"path": "/src/svd/usage.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tests = vec![
(Usage::Read, "<usage>read</usage>"),
(Usage::Write, "<usage>write</usage>"),
(Usage::ReadWrite, "<usage>read-write</usage>"),
];
run_test::<Usage>(&tests[..]);
}
}<|fim_prefix|>// repo: WRansohoff/svd path: /src/svd/usage... | code_fim | hard | {
"lang": "rust",
"repo": "WRansohoff/svd",
"path": "/src/svd/usage.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 1byte2bytes/xxchain path: /xx-team-custody/src/benchmarking.rs
// Added as part the code review and testing
// by ChainSafe Systems Aug 2021
use super::*;
use crate::Module as XXCustody;
use frame_benchmarking::{benchmarks, account, impl_benchmark_test_suite};
use frame_system::RawOrigin;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "1byte2bytes/xxchain",
"path": "/xx-team-custody/src/benchmarking.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> // run to the end of the custody period
frame_system::Pallet::<T>::set_block_number(T::CustodyDuration::get());
}: _(RawOrigin::Signed(team.clone()), team.clone())
custody_bond {
let team = team_member::<T>();
let custodian = custodian::<T>();
let amount = <<T as pallet_staking::Config>::Cu... | code_fim | hard | {
"lang": "rust",
"repo": "1byte2bytes/xxchain",
"path": "/xx-team-custody/src/benchmarking.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BrianMcKeever/My-exercism-solutions path: /rust/simple-linked-list/src/lib.rs
use std::iter::FromIterator;
pub struct SimpleLinkedList<T>
where
T: std::clone::Clone,
{
head: Option<Box<Node<T>>>,
}
struct Node<T>
where
T: std::clone::Clone,
{
data: T,
next: Option<Box<Node<... | code_fim | hard | {
"lang": "rust",
"repo": "BrianMcKeever/My-exercism-solutions",
"path": "/rust/simple-linked-list/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> FromIterator<T> for SimpleLinkedList<T>
where
T: std::clone::Clone,
{
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
let mut list = SimpleLinkedList::new();
for i in iter {
list.push(i);
}
list
}
}
// In general, it would be pref... | code_fim | hard | {
"lang": "rust",
"repo": "BrianMcKeever/My-exercism-solutions",
"path": "/rust/simple-linked-list/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "../../emtests/test_globaldoubles.out"
);
}<|fim_prefix|>// repo: forkkit/wasmer path: /lib/emscripten-tests/tests/emtests/test_globaldoubles.rs
#[test]
fn test_test_globaldoubles() {
assert_emscripten_output!(
"../../emtests/test_globaldouble<|fim_middle|>s.wasm",
"test_g... | code_fim | easy | {
"lang": "rust",
"repo": "forkkit/wasmer",
"path": "/lib/emscripten-tests/tests/emtests/test_globaldoubles.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>s.wasm",
"test_globaldoubles",
vec![],
"../../emtests/test_globaldoubles.out"
);
}<|fim_prefix|>// repo: forkkit/wasmer path: /lib/emscripten-tests/tests/emtests/test_globaldoubles.rs
#[test]
fn test_test_globaldoubles() {
assert_emscr<|fim_middle|>ipten_output!(
"... | code_fim | easy | {
"lang": "rust",
"repo": "forkkit/wasmer",
"path": "/lib/emscripten-tests/tests/emtests/test_globaldoubles.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forkkit/wasmer path: /lib/emscripten-tests/tests/emtests/test_globaldoubles.rs
#[test]
fn test_test_globaldoubles() {
assert_emscripten_output!(
"../../emtests/test_globaldouble<|fim_suffix|> "../../emtests/test_globaldoubles.out"
);
}<|fim_middle|>s.wasm",
"test_g... | code_fim | easy | {
"lang": "rust",
"repo": "forkkit/wasmer",
"path": "/lib/emscripten-tests/tests/emtests/test_globaldoubles.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod decoder;
mod encoder;
mod event;
mod handshake;
mod lines;
mod message;
pub use decoder::{decode, Decoder};
pub use encoder::{encode, Encoder, Sender};
pub use event::Event;
pub use handshake::upgrade;
pub use message::Message;
pub(crate) use lines::Lines;<|fim_prefix|>// repo: RangerStation/alexand... | code_fim | medium | {
"lang": "rust",
"repo": "RangerStation/alexandrie-run",
"path": "/.cargo/registry/src/github.com-1ecc6299db9ec823/async-sse-3.0.0/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
:
:
new
(
io
:
:
ErrorKind
:
:
Other
"
path
canonicalization
error
"
)
;
Url
:
:
from_file_path
(
&
canonical
)
.
and_then
(
|
url
|
url
.
to_file_path
(
)
)
.
map_err
(
map_err
)
?
}
else
{
canonical
}
)
}<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/rk... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/rkv/src/helpers.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>(
path
:
P
)
-
>
io
:
:
Result
<
PathBuf
>
where
P
:
Into
<
&
'
p
Path
>
{
let
canonical
=
path
.
into
(
)
.
canonicalize
(
)
?
;
Ok
(
if
cfg
!
(
target_os
=
"
windows
"
)
{
let
map_err
=
|
_
|
io
:
:
Error
:
:
new
(
io
:
:
ErrorKind
:
:
Other
"
path
canonicalization
error
"
)
;
Url
:
:
from_file_path
(
&... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/rkv/src/helpers.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/rkv/src/helpers.rs
use
std
:
:
{
io
path
:
:
{
Path
PathBuf
}
}
;
use
url
:
:
Url
;
use
crate
:
:
{
error
:
:
StoreError
value
:
:
Value
}
;
pub
(
crate
)
fn
read_transform
(
value
:
Result
<
&
[
u8
]
StoreError
>
)
-
>
Res... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/rkv/src/helpers.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asingingbird/show path: /src/main.rs
mod completion;
mod count;
mod diff;
mod location;
mod path;
mod utils;
mod walk;
mod which;
use completion::*;
use diff::*;
use path::*;
use utils::*;
use which::*;
use crate::location::run_location;
use ansi_term::Color::*;
use clap::App;
use fern::colors... | code_fim | medium | {
"lang": "rust",
"repo": "asingingbird/show",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match matches.subcommand() {
("which", Some(m)) => WhichCommand::run(m),
("path", Some(m)) => PathCommand::run(m),
("diff", Some(m)) => DiffCommand::run(m),
("generate-completions", Some(m)) => CompletionCommand::run(m),
_ => {}
}
}<|fim_prefix|>// repo: asi... | code_fim | hard | {
"lang": "rust",
"repo": "asingingbird/show",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: switefaster/multi_pong path: /multi_pong/src/systems/winner.rs
use crate::constants::SCENE_WIDTH;
use crate::network::NetworkCommunication;
use crate::systems::Ball;
use amethyst::{
core::transform::Transform,
derive::SystemDesc,
ecs::prelude::{Join, Read, System, SystemData, WriteSt... | code_fim | hard | {
"lang": "rust",
"repo": "switefaster/multi_pong",
"path": "/multi_pong/src/systems/winner.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn run(&mut self, (mut balls, mut locals, comm): Self::SystemData) {
if comm.is_server() {
for (ball, transform) in (&mut balls, &mut locals).join() {
let ball_x = transform.translation().x;
let did_hit = if ball_x <= -ball.radius {
... | code_fim | hard | {
"lang": "rust",
"repo": "switefaster/multi_pong",
"path": "/multi_pong/src/systems/winner.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mineichen/aoc2020 path: /day2/src/part2.rs
mod lib;
fn main() {
let rules = lib::load_rules();
let valid = rules
.map(Result::unwrap)
.filter(|(rule, text)| rule.is_valid(&text))
.count();
println!("Valid passwords: {}", valid);
}
<|fim_suffix|> input... | code_fim | hard | {
"lang": "rust",
"repo": "mineichen/aoc2020",
"path": "/day2/src/part2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input
.chars()
.skip(pos - 1)
.map(|c| c == self.char)
.next()
.unwrap_or(false)
}
}<|fim_prefix|>// repo: mineichen/aoc2020 path: /day2/src/part2.rs
mod lib;
fn main() {
let rules = lib::load_rules();
let valid = rules
... | code_fim | hard | {
"lang": "rust",
"repo": "mineichen/aoc2020",
"path": "/day2/src/part2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
from: Self::Peer,
msg: Self::Message,
) -> Vec<(Self::Peer, Self::Message)> {
match msg {
ClientReq { req_id } => self.propose(from, req_id),
ClientRes { .. } => {
panic!("somehow received a ClientRes: {:?}", msg)
... | code_fim | hard | {
"lang": "rust",
"repo": "siler/sled",
"path": "/crates/simulator/tests/idgen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: siler/sled path: /crates/simulator/tests/idgen.rs
extern crate bincode;
extern crate deterministic;
extern crate serde;
extern crate simulator;
#[macro_use]
extern crate serde_derive;
use std::collections::HashMap;
use deterministic::Reactor;
type ReqId = usize;
struct IdGen {
peers: Vec... | code_fim | hard | {
"lang": "rust",
"repo": "siler/sled",
"path": "/crates/simulator/tests/idgen.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: d3v3l0/datafusion-benchmarks path: /src/main/rust/generate-wkt/src/main.rs
use std::collections::HashMap;
use std::rc::Rc;
use std::time::Instant;
extern crate arrow;
use arrow::datatypes::*;
extern crate datafusion;
use datafusion::exec::*;
use datafusion::functions::geospatial::*;
use datafu... | code_fim | medium | {
"lang": "rust",
"repo": "d3v3l0/datafusion-benchmarks",
"path": "/src/main/rust/generate-wkt/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ctx.write_csv(df, &output_filename).unwrap();
let duration = now.elapsed();
let seconds = duration.as_secs() as f64 + (duration.subsec_nanos() as f64 / 1000000000.0);
println!(
"Elapsed time for {} locations is {} seconds ({} rows per second)",
n,
seconds,
... | code_fim | hard | {
"lang": "rust",
"repo": "d3v3l0/datafusion-benchmarks",
"path": "/src/main/rust/generate-wkt/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: infinityb/snek path: /surface/src/netpbm_loader.rs
use netpbm::{PpmPixel, PpmLoadResult, PpmLoadError, FromPpm};
use super::{ColorRGBA, Channel, Colorspace};
use super::Surface;
<|fim_suffix|> for (idx, pixel) in pixels.enumerate() {
let x = idx % width;
let y = ... | code_fim | hard | {
"lang": "rust",
"repo": "infinityb/snek",
"path": "/surface/src/netpbm_loader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (idx, pixel) in pixels.enumerate() {
let x = idx % width;
let y = idx / width;
let PpmPixel(r, g, b) = try!(pixel);
surface[(x, y)] = ColorRGBA::new_rgb(r as u8, g as u8, b as u8);
}
Ok(surface)
}
}<|fim_prefix|>// repo: infi... | code_fim | hard | {
"lang": "rust",
"repo": "infinityb/snek",
"path": "/surface/src/netpbm_loader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn compressed_len(b: &mut Bencher) {
let h = huffman_default();
let test_cases = test_cases();
b.iter(|| {
for &(ref uncompressed, _) in &test_cases {
black_box(h.compressed_len(uncompressed));
}
});
b.bytes = test_cases.iter().map(|&(ref uncompressed, _)| u... | code_fim | hard | {
"lang": "rust",
"repo": "heinrich5991/libtw2",
"path": "/huffman/benches/compression.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heinrich5991/libtw2 path: /huffman/benches/compression.rs
#[macro_use] extern crate bencher;
extern crate buffer;
extern crate common;
extern crate huffman;
extern crate huffman_reference;
extern crate itertools;
use bencher::Bencher;
use bencher::black_box;
use common::num::Cast;
use huffman::... | code_fim | hard | {
"lang": "rust",
"repo": "heinrich5991/libtw2",
"path": "/huffman/benches/compression.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vilunov/intuitive-messenger-compressors path: /src/shannon_fano.rs
use bit_vec::BitVec;
use std::collections::HashMap;
fn slovar_encode(freqs: &Vec<(u8, u32)>) -> HashMap<u8, BitVec> {
fn update_map(map: &mut HashMap<u8, BitVec>, freqs: &Vec<(u8, u32)>, from: usize, to: usize, mut bit_vec: ... | code_fim | hard | {
"lang": "rust",
"repo": "vilunov/intuitive-messenger-compressors",
"path": "/src/shannon_fano.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn decode(input: &[u8]) -> Option<Vec<u8>> {
if input.len() < 256 * 4 + 1 {
return None;
}
let mut freqs: [u32; 256] = unsafe { ::std::mem::uninitialized() };
let mut bits = BitVec::from_bytes(&input[0..input.len() - 256 * 4 - 1]);
{
use std::io::Cursor;
use... | code_fim | hard | {
"lang": "rust",
"repo": "vilunov/intuitive-messenger-compressors",
"path": "/src/shannon_fano.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> MDBookType::TopOfBook
}
}
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq)]
pub enum ApplQueueResolution {
/// No action taken
#[serde(rename = "0")]
NoActionTaken,
/// Queue Flushed
#[serde(rename = "1")]
QueueFlushed,
/// Overlay Last
#[serde(rename = "2")]
OverlayLast,
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "lnicola/serde_fix",
"path": "/fix50sp2/src/messages/market_data_incremental_refresh.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lnicola/serde_fix path: /fix50sp2/src/messages/market_data_incremental_refresh.rs
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct MarketDataIncrementalRefresh {
/// MsgType = X
#[serde(flatten)]
pub standard_message_header:... | code_fim | hard | {
"lang": "rust",
"repo": "lnicola/serde_fix",
"path": "/fix50sp2/src/messages/market_data_incremental_refresh.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: germansmedia/commedia path: /src/opengl45/mod.rs
// (C) Copyright 2020, by Germans Media Technology & Services
// Commedia
// OpenGL 4.5
<|fim_suffix|>mod framebuffer;
pub use framebuffer::*;
mod vertexbuffer;
pub use vertexbuffer::*;<|fim_middle|>mod shader;
pub use shader::*;
mod texture2d;... | code_fim | medium | {
"lang": "rust",
"repo": "germansmedia/commedia",
"path": "/src/opengl45/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod framebuffer;
pub use framebuffer::*;
mod vertexbuffer;
pub use vertexbuffer::*;<|fim_prefix|>// repo: germansmedia/commedia path: /src/opengl45/mod.rs
// (C) Copyright 2020, by Germans Media Technology & Services
// Commedia
// OpenGL 4.5
mod shader;
pub use shader::*;
<|fim_middle|>mod texture2d;... | code_fim | easy | {
"lang": "rust",
"repo": "germansmedia/commedia",
"path": "/src/opengl45/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brockelmore/makepad path: /makepad/app/src/lib.rs
pub mod keyboard;
pub mod fileeditor;
pub mod filepanel;
pub mod homepage;
pub mod loglist;
pub mod makepadapp;
pub use crate::makepadapp::*;
pub mod a<|fim_suffix|>lorpicker;
pub mod floatslider;
//mod rustcompiler;
//pub use crate::rustcompiler... | code_fim | hard | {
"lang": "rust",
"repo": "brockelmore/makepad",
"path": "/makepad/app/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>lorpicker;
pub mod floatslider;
//mod rustcompiler;
//pub use crate::rustcompiler::*;
pub use makepad_render::*;
pub mod builder;
pub mod mprstokenizer;<|fim_prefix|>// repo: brockelmore/makepad path: /makepad/app/src/lib.rs
pub mod keyboard;
pub mod fileeditor;
pub mod filepanel;
pub mod homepage;
pub m... | code_fim | hard | {
"lang": "rust",
"repo": "brockelmore/makepad",
"path": "/makepad/app/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let total_sum = weights.iter().sum::<usize>();
let target = total_sum / 3;
let mut min_qe = usize::MAX;
build_groups(&weights, target, 0, 1, &mut min_qe);
println!("part1: {}", min_qe);
let target = total_sum / 4;
let mut min_qe = usize::MAX;
build_groups(&weights, target, ... | code_fim | hard | {
"lang": "rust",
"repo": "tristan/adventofcode2015",
"path": "/src/day_24.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tristan/adventofcode2015 path: /src/day_24.rs
use std::fs::File;
use std::io::{BufRead, BufReader};
fn build_groups(
values: &[usize],
target: usize,
sum: usize,
qe: usize,
min_qe: &mut usize
) {
(0..values.len()).for_each(|i| {
let sum = sum + values[i];
... | code_fim | medium | {
"lang": "rust",
"repo": "tristan/adventofcode2015",
"path": "/src/day_24.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: truexin1292/tauri path: /tauri/src/app/webview/wry.rs
use super::{
ApplicationDispatcherExt, ApplicationExt, Callback, Icon, WebviewBuilderExt,
WebviewBuilderExtPrivate, WindowConfig,
};
use once_cell::sync::Lazy;
use crate::plugin::PluginStore;
use std::{
convert::{TryFrom, TryInto},
... | code_fim | hard | {
"lang": "rust",
"repo": "truexin1292/tauri",
"path": "/tauri/src/app/webview/wry.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self
.0
.lock()
.unwrap()
.set_position(x, y)
.map_err(|_| crate::Error::FailedToSendMessage)
}
fn set_fullscreen(&self, fullscreen: bool) -> crate::Result<()> {
self
.0
.lock()
.unwrap()
.set_fullscreen(fullscreen)
.map_err(|_| crat... | code_fim | hard | {
"lang": "rust",
"repo": "truexin1292/tauri",
"path": "/tauri/src/app/webview/wry.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukaspustina/usereport-rs path: /examples/json_report.rs
use usereport::{Analysis, Config, Context, JsonRenderer, Renderer, ThreadRunner};
fn main() {
#[cfg(target_os = "macos")]
let config = Config::from_file("contrib/osx.conf").expect("Failed to load config file");
#[cfg(target_os... | code_fim | hard | {
"lang": "rust",
"repo": "lukaspustina/usereport-rs",
"path": "/examples/json_report.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let runner = ThreadRunner::new();
let hostinfos = config.commands_for_hostinfo();
let analysis = Analysis::new(Box::new(runner), &hostinfos, &config.commands);
let context = Context::new().expect("failed to create context");
let report = analysis.run(context).expect("failed to run anal... | code_fim | hard | {
"lang": "rust",
"repo": "lukaspustina/usereport-rs",
"path": "/examples/json_report.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: argmin-rs/argmin path: /argmin/src/solver/linesearch/condition/goldstein.rs
// Copyright 2018-2022 argmin developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/lice... | code_fim | hard | {
"lang": "rust",
"repo": "argmin-rs/argmin",
"path": "/argmin/src/solver/linesearch/condition/goldstein.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_error!(
GoldsteinCondition::new(-1.0f64),
ArgminError,
"Invalid parameter: \"GoldsteinCondition: Parameter c must be in (0, 0.5)\""
);
}
#[test]
fn test_goldstein() {
let c: f64 = 0.1;
let cond = GoldsteinCondition::ne... | code_fim | hard | {
"lang": "rust",
"repo": "argmin-rs/argmin",
"path": "/argmin/src/solver/linesearch/condition/goldstein.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: communityvi/communityvi path: /communityvi-server/hyper-test/src/lib.rs
mod client;
mod connection;
mod error;
mod executor;
mod host;
mod request_builder;
mod response;
mod serve;
<|fim_suffix|>pub use connection::connection_incoming::ConnectionIncoming;
pub use connection::connector::Connecto... | code_fim | medium | {
"lang": "rust",
"repo": "communityvi/communityvi",
"path": "/communityvi-server/hyper-test/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use connection::connection_incoming::ConnectionIncoming;
pub use connection::connector::Connector;
pub use host::Host;
pub use serve::serve;<|fim_prefix|>// repo: communityvi/communityvi path: /communityvi-server/hyper-test/src/lib.rs
mod client;
mod connection;
mod error;
mod executor;
mod host;
mod... | code_fim | medium | {
"lang": "rust",
"repo": "communityvi/communityvi",
"path": "/communityvi-server/hyper-test/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: plol/adventofcode2020 path: /src/codegen_stuff.rs
extern crate proc_macro;
extern crate syn;
#[macro_use]
extern crate quote;
use quote::quote;
struct ScanInput {
pattern: syn::LitStr,
to_parse: syn::Expr,
}
impl syn::parse::Parse for ScanInput {
fn parse(input: syn::parse::Parse... | code_fim | hard | {
"lang": "rust",
"repo": "plol/adventofcode2020",
"path": "/src/codegen_stuff.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut i = 0;
#parse_blobs
(#(#outputs),*)
}
})
.into()
}
#[proc_macro]
pub fn scan(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let ScanInput { pattern, to_parse } = syn::parse_macro_input!(input as ScanInput);
let outputs = p... | code_fim | hard | {
"lang": "rust",
"repo": "plol/adventofcode2020",
"path": "/src/codegen_stuff.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nimiq/core-rs-albatross path: /blockchain/tests/history_sync.rs
use std::sync::Arc;
use nimiq_block_production::BlockProducer;
use nimiq_blockchain::{Blockchain, BlockchainConfig};
use nimiq_blockchain_interface::{AbstractBlockchain, PushResult};
use nimiq_database::volatile::VolatileDatabase;
... | code_fim | hard | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/blockchain/tests/history_sync.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
Blockchain::push_history_sync(
blockchain2.upgradable_read(),
checkpoint_block_2_3,
&checkpoint_txs_2_3
),
Ok(PushResult::Extended)
);
assert_eq!(
Blockchain::push_history_sync(
blockchain2.upgradable_... | code_fim | hard | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/blockchain/tests/history_sync.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ileReader/readAsArrayBuffer)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Blob`, `FileReader`*"]
pub fn read_as_array_buffer(this: &FileReader, blob: &Blob) -> Result<(), JsValue>;
#[cfg(feature = "Blob")]
# [wasm_bindgen (catch , method , st... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_FileReader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /crates/web-sys/src/features/gen_FileReader.rs
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = EventTarget , extends = :: js_sys :: Object , js_name = FileReader ,... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_FileReader.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Json(ResVO::<HomeVO>::from_result(Some(res)))
}
Err(err) => {
tracing::error!("Get_good_list: {:?}.", err);
Json(ResVO::from_error(None, err.to_string(), None))
}
}
}<|fim_prefix|>// repo: SummerSnake/taro-shop path: /back/rust/src/handlers... | code_fim | hard | {
"lang": "rust",
"repo": "SummerSnake/taro-shop",
"path": "/back/rust/src/handlers/home_handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SummerSnake/taro-shop path: /back/rust/src/handlers/home_handler.rs
use crate::config::Pager;
use crate::dtos::{ad_dto, good_dto, home_dto};
use crate::models::{ad::AdUrlParams, home::HomeVO};
use crate::response::ResVO;
use axum::{extract::Query, response::IntoResponse, Json};
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "SummerSnake/taro-shop",
"path": "/back/rust/src/handlers/home_handler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
json_value_to_message_item(&serde_json::from_str("[1]").unwrap(), b"ay"),
Some(MessageItem::Array(
MessageItemArray::new(
vec![MessageItem::Byte(1)],
Signature::new("ay".as_bytes()).unwrap()
... | code_fim | hard | {
"lang": "rust",
"repo": "mrk-its/dbus-mqtt",
"path": "/src/dbus_json.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mrk-its/dbus-mqtt path: /src/dbus_json.rs
use dbus::arg;
use dbus::arg::messageitem::{MessageItem, MessageItemArray, MessageItemDict};
use dbus::strings::Signature;
use json::Value;
use serde_json as json;
#[derive(Debug, PartialEq)]
pub enum Sig {
Array(Box<Sig>),
KV(Box<Sig>, Box<Sig>... | code_fim | hard | {
"lang": "rust",
"repo": "mrk-its/dbus-mqtt",
"path": "/src/dbus_json.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn variant_to_json(value: &arg::Variant<Box<dyn arg::RefArg>>) -> Option<String> {
Some(refarg_to_json(&value.0)?.to_string())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn parse_simple_type() {
assert_eq!(
parse_signature(&mut b"y".iter()),
Some(... | code_fim | hard | {
"lang": "rust",
"repo": "mrk-its/dbus-mqtt",
"path": "/src/dbus_json.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn run_with_message() {
test::run_script_and_error(vec![create("")], "out = trigger_error msg", "out");
}<|fim_prefix|>// repo: sagiegurari/duckscript path: /duckscript_sdk/src/sdk/std/on_error/trigger_error/mod_test.rs
use super::*;
use crate::test;
#[test]
fn common_functions() {
<|fim_mid... | code_fim | medium | {
"lang": "rust",
"repo": "sagiegurari/duckscript",
"path": "/duckscript_sdk/src/sdk/std/on_error/trigger_error/mod_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sagiegurari/duckscript path: /duckscript_sdk/src/sdk/std/on_error/trigger_error/mod_test.rs
use super::*;
use crate::test;
#[test]
fn common_functions() {
test::test_common_command_functions(create(""));
}
<|fim_suffix|>#[test]
fn run_with_message() {
test::run_script_and_error(vec![cr... | code_fim | medium | {
"lang": "rust",
"repo": "sagiegurari/duckscript",
"path": "/duckscript_sdk/src/sdk/std/on_error/trigger_error/mod_test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> test::run_script_and_error(vec![create("")], "out = trigger_error msg", "out");
}<|fim_prefix|>// repo: sagiegurari/duckscript path: /duckscript_sdk/src/sdk/std/on_error/trigger_error/mod_test.rs
use super::*;
use crate::test;
#[test]
fn common_functions() {
test::test_common_command_functions(c... | code_fim | medium | {
"lang": "rust",
"repo": "sagiegurari/duckscript",
"path": "/duckscript_sdk/src/sdk/std/on_error/trigger_error/mod_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stjordanis/litentry-juniper-api path: /substrate/tests/src/test_chain.rs
#[macro_use]
extern crate jsonrpc_core_client;
extern crate futures;
extern crate substrate_rpc;
extern crate node_primitives;
extern crate hyper;
extern crate sr_primitives;
extern crate node_runtime;
use futures::Future;... | code_fim | hard | {
"lang": "rust",
"repo": "stjordanis/litentry-juniper-api",
"path": "/substrate/tests/src/test_chain.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>:{Address, Block, Header, SignedBlock};
//pub fn test_chain() {
//
// rt::run(rt::lazy(|| {
// let uri = "http://192.168.2.158:9933";
//
// http::connect(uri)
// .and_then(|client: ChainClient<Hash, Hash, Header, SignedBlock>| {
// get_chain_api(&client)
// ... | code_fim | hard | {
"lang": "rust",
"repo": "stjordanis/litentry-juniper-api",
"path": "/substrate/tests/src/test_chain.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn retire_stake_pool(
stake_pool_id: &str,
account: &mut Wallet,
genesis_block_hash: &str,
valid_until: BlockDate,
jormungandr: &JormungandrProcess,
wait: &Wait,
) {
let temp_dir = TempDir::new().unwrap();
let jcli: JCli = Default::default();
let owner_stake_key = ... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/testing/jormungandr-integration-tests/src/jormungandr/genesis/stake_pool.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let transaction = jcli
.transaction_builder(block0_hash)
.new_transaction()
.add_account(&account.address().to_string(), &fee_value)
.add_certificate(&stake_pool_delegation)
.set_expiry_date(valid_until)
.finalize_with_fee(&account.address().to_string(),... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/testing/jormungandr-integration-tests/src/jormungandr/genesis/stake_pool.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: katoozi/rust-practices path: /user_defined_types/src/main.rs
struct Color(u8, u8, u8);
struct Player {
name: String,
iq: u8,
friends: u8,
score: u16,
}
impl Player {
fn new() -> Player {
Player {
name: "test".to_owned(),
iq: 10,
f... | code_fim | medium | {
"lang": "rust",
"repo": "katoozi/rust-practices",
"path": "/user_defined_types/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("red: {}, blue: {}", r, b);
let mut player = Player::new();
player.name = "mohammad".to_string();
bump_player(player, 10);
}
fn bump_player(mut player: Player, score: u16) {
player.score += score;
println!("Name: {}", player.name);
println!("IQ: {}", player.iq);
... | code_fim | medium | {
"lang": "rust",
"repo": "katoozi/rust-practices",
"path": "/user_defined_types/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::Unknown
}
}
/// Actor data returned by [`Client::series_actors`].
///
/// See linked method for more info.
///
/// [`Client::series_actors`]: ../client/struct.Client.html#method.series_actors
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr(test, derive(Default)... | code_fim | hard | {
"lang": "rust",
"repo": "roignpar/thetvdb",
"path": "/src/response.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: roignpar/thetvdb path: /src/response.rs
, Eq, Deserialize, Serialize,
)]
pub struct SeriesID(pub u32);
impl fmt::Display for SeriesID {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl From<u32> for SeriesID {
fn from(i: u32) -> Se... | code_fim | hard | {
"lang": "rust",
"repo": "roignpar/thetvdb",
"path": "/src/response.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: roignpar/thetvdb path: /src/response.rs
Series`, but can be used
/// to get all the data.
///
/// See [`Client::search`] and [`Client::series`] for more info.
///
/// [`Client::search`]: ../client/struct.Client.html#method.search
/// [`Client::series`]: ../client/struct.Client.html#method.series... | code_fim | hard | {
"lang": "rust",
"repo": "roignpar/thetvdb",
"path": "/src/response.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emirayka/nia_interpreter_core path: /src/interpreter/environment/environment_id.rs
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct EnvironmentId {
index: usize,
}
<|fim_suffix|> pub fn get_id(&self) -> usize {
self.index
}
}<|fim_middle|>impl EnvironmentId {
... | code_fim | medium | {
"lang": "rust",
"repo": "emirayka/nia_interpreter_core",
"path": "/src/interpreter/environment/environment_id.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_id(&self) -> usize {
self.index
}
}<|fim_prefix|>// repo: emirayka/nia_interpreter_core path: /src/interpreter/environment/environment_id.rs
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct EnvironmentId {
index: usize,
}
<|fim_middle|>impl EnvironmentId {
... | code_fim | medium | {
"lang": "rust",
"repo": "emirayka/nia_interpreter_core",
"path": "/src/interpreter/environment/environment_id.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: roy-ganz/toql path: /tests/left_join.rs
use toql::mock_db::MockDb;
use toql::prelude::{fields, paths, query, Cache, Join, Toql, ToqlApi};
use tracing_test::traced_test;
//
#[derive(Debug, Default, Toql)]
pub struct Level1 {
#[toql(key)]
id: u64,
text: String,
#[toql(join, presel... | code_fim | hard | {
"lang": "rust",
"repo": "roy-ganz/toql",
"path": "/tests/left_join.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::test]
#[traced_test("info")]
async fn insert2() {
let cache = Cache::new();
let mut toql = MockDb::from(&cache);
let mut l = Level4 {
id: 4,
text: "level4".to_string(),
level5: Some(Some(Join::with_key(5))),
};
// insert level 4 with joined key
as... | code_fim | hard | {
"lang": "rust",
"repo": "roy-ganz/toql",
"path": "/tests/left_join.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pgerber/rust-socks path: /src/v5.rs
use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian};
use std::cmp;
use std::io::{self, Read, Write, BufReader};
use std::net::{SocketAddr, ToSocketAddrs, SocketAddrV4, SocketAddrV6, TcpStream, Ipv4Addr,
Ipv6Addr, UdpSocket};
use std::ptr;
u... | code_fim | hard | {
"lang": "rust",
"repo": "pgerber/rust-socks",
"path": "/src/v5.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", String::from_utf8_lossy(&result));
assert!(result.starts_with(b"HTTP/1.0"));
assert!(result.ends_with(b"</HTML>\r\n") || result.ends_with(b"</html>"));
}
#[test]
fn bind() {
// First figure out our local address that we'll be connecting from
... | code_fim | hard | {
"lang": "rust",
"repo": "pgerber/rust-socks",
"path": "/src/v5.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn google_dns() {
let mut socket = Socks5Stream::connect("127.0.0.1:1080", "google.com:80").unwrap();
socket.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap();
let mut result = vec![];
socket.read_to_end(&mut result).unwrap();
println!("{}", String::fr... | code_fim | hard | {
"lang": "rust",
"repo": "pgerber/rust-socks",
"path": "/src/v5.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: olson-sean-k/gaudium path: /gaudium-core/src/framework/input/mod.rs
mod keyboard;
mod mouse;
mod state;
pub use self::keyboard::{KeyboardSnapshot, KeyboardState};
pub use self::mouse::{MousePosition,<|fim_suffix|>{CompositeState, Snapshot, SnapshotDifference, SnapshotTransition};<|fim_middle|> ... | code_fim | medium | {
"lang": "rust",
"repo": "olson-sean-k/gaudium",
"path": "/gaudium-core/src/framework/input/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> MouseProximity, MouseSnapshot, MouseState};
pub use self::state::{CompositeState, Snapshot, SnapshotDifference, SnapshotTransition};<|fim_prefix|>// repo: olson-sean-k/gaudium path: /gaudium-core/src/framework/input/mod.rs
mod keyboard;
mod mouse;
mod state;
pub use self::keyboard::{Keyb<|fim_middle|>o... | code_fim | medium | {
"lang": "rust",
"repo": "olson-sean-k/gaudium",
"path": "/gaudium-core/src/framework/input/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// Register the eventfd with mio
struct AioEventFd {
inner: EventFD,
}
impl mio::Evented for AioEventFd {
fn register(&self,
poll: &mio::Poll,
token: mio::Token,
interest: mio::Ready,
opts: mio::PollOpt)
-> io::Resul... | code_fim | hard | {
"lang": "rust",
"repo": "knutin/protostore",
"path": "/src/aio.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: knutin/protostore path: /src/aio.rs
use std::io;
use std::default::Default;
use std::thread::{self, JoinHandle};
use std::time::SystemTime;
use mio;
use futures::{Future, Async, Poll};
use futures::{oneshot, Complete};
use futures::stream::{Stream, Fuse};
use futures::sync::mpsc;
use tokio_cor... | code_fim | hard | {
"lang": "rust",
"repo": "knutin/protostore",
"path": "/src/aio.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //let handle1 = session.handle();
//let handle2 = session.handle();
// let reads = (0..5).map(|_| {
// println!("foo");
// let file = DirectFile::open(path.clone(), Mode::Open, FileAccess::Read, 4096).unwrap();
// let mut buf = BytesMut::with_ca... | code_fim | hard | {
"lang": "rust",
"repo": "knutin/protostore",
"path": "/src/aio.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: faern/leakruntime path: /src/main.rs
use std::time::Duration;
const DELAY: Duration = Duration::from_millis(1);
#[cfg(not(feature = "tokio"))]
#[async_std::main]
async fn main() {
async_std::task::sleep(DELAY).await;
}
<|fim_suffix|> tokio::runtime::Builder::new()
.basic_schedu... | code_fim | hard | {
"lang": "rust",
"repo": "faern/leakruntime",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.