text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> fn get_next_timeout(&self) -> Option<Duration> {
let times = self.applications.iter().fold(Vec::new(), |mut times, app| {
if let Some(t) = app.kill_time {
times.push(t);
}
if let Some(t) = app.start_time {
times.push(t);
... | code_fim | hard | {
"lang": "rust",
"repo": "pwFoo/riffol",
"path": "/src/init.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pwFoo/riffol path: /src/init.rs
// Copyright (c) 2018, [Ribose Inc](https://www.ribose.com).
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain... | code_fim | hard | {
"lang": "rust",
"repo": "pwFoo/riffol",
"path": "/src/init.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut starts = self
.applications
.iter()
.enumerate()
.filter(|(_, app)| app.inner.is_idle())
.filter(|(_, app)| app.start_time.map(|t| t <= Instant::now()).unwrap_or(true))
.filter(|(_, app)| {
app.depends.... | code_fim | hard | {
"lang": "rust",
"repo": "pwFoo/riffol",
"path": "/src/init.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: onevcat/slack-morphism-rust path: /src/models/src/events/authorization.rs
use rsb_derive::Builder;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
<|fim_suffix|>#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct Sl... | code_fim | easy | {
"lang": "rust",
"repo": "onevcat/slack-morphism-rust",
"path": "/src/models/src/events/authorization.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: osoy/osoy path: /src/operator/unlink.rs
use crate::{link, repo, Config, Exec, Location};
use std::fs;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(about = "Remove symbolic links")]
pub struct Opt {
#[structopt(short, long, help = "Use regular expressions")]
pub rege... | code_fim | hard | {
"lang": "rust",
"repo": "osoy/osoy",
"path": "/src/operator/unlink.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut errors = 0;
match repo::iterate_matching_exists(&config.src, self.targets, self.regex) {
Ok(iter) => {
if let Ok(iter) = link::iterate(&config.bin, iter.collect()) {
for (sym, dest) in iter {
if self.force
... | code_fim | hard | {
"lang": "rust",
"repo": "osoy/osoy",
"path": "/src/operator/unlink.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DRvader/AOC2020 path: /src/lib.rs
#![allow(non_snake_case)]
use std::{
error::Error,
fs::File,
io::Read,
path::{Path, PathBuf},
};
<|fim_suffix|>pub fn read_datafile<P: AsRef<Path>>(path: P) -> Result<String, Box<dyn Error>> {
let mut file = File::open(get_datadir()?.join(p... | code_fim | hard | {
"lang": "rust",
"repo": "DRvader/AOC2020",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn read_datafile<P: AsRef<Path>>(path: P) -> Result<String, Box<dyn Error>> {
let mut file = File::open(get_datadir()?.join(path))?;
let mut buf = String::new();
file.read_to_string(&mut buf)?;
return Ok(buf);
}<|fim_prefix|>// repo: DRvader/AOC2020 path: /src/lib.rs
#![allow(non_snake_c... | code_fim | hard | {
"lang": "rust",
"repo": "DRvader/AOC2020",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rnbguy/vt3-rs path: /src/ip/response.rs
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Root {
pub data: Data,
}
#[derive(Default, Debug, Clone, PartialEq, ... | code_fim | hard | {
"lang": "rust",
"repo": "rnbguy/vt3-rs",
"path": "/src/ip/response.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|><Vec<u32>>();
b.iter(|| {
v.iter().fold(0u32, |old, new| old.pow(*new as u32));
});
}<|fim_prefix|>// repo: solana-labs/rust-bpf-sysroot path: /src/std/src/num/benches.rs
use test::Bencher;
#[bench]
fn bench_pow_function<|fim_middle|>(b: &mut Bencher) {
let v = (0..1024).collect:: | code_fim | easy | {
"lang": "rust",
"repo": "solana-labs/rust-bpf-sysroot",
"path": "/src/std/src/num/benches.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>d(0u32, |old, new| old.pow(*new as u32));
});
}<|fim_prefix|>// repo: solana-labs/rust-bpf-sysroot path: /src/std/src/num/benches.rs
use test::Bencher;
#[bench]
fn bench_pow_function(b: &mut Bencher) {
let v = (0..1024).collect::<|fim_middle|><Vec<u32>>();
b.iter(|| {
v.iter().fol | code_fim | easy | {
"lang": "rust",
"repo": "solana-labs/rust-bpf-sysroot",
"path": "/src/std/src/num/benches.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: solana-labs/rust-bpf-sysroot path: /src/std/src/num/benches.rs
use test::Bencher;
#[bench]
fn bench_pow_function<|fim_suffix|>d(0u32, |old, new| old.pow(*new as u32));
});
}<|fim_middle|>(b: &mut Bencher) {
let v = (0..1024).collect::<Vec<u32>>();
b.iter(|| {
v.iter().fol | code_fim | medium | {
"lang": "rust",
"repo": "solana-labs/rust-bpf-sysroot",
"path": "/src/std/src/num/benches.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result =
spirv_builder::SpirvBuilder::new("../simple-rt-shader", "spirv-unknown-vulkan1.2")
.capability(spirv_builder::Capability::RayTracingKHR)
.capability(spirv_builder::Capability::ImageQuery)
.extension("SPV_KHR_ray_tracing")
... | code_fim | hard | {
"lang": "rust",
"repo": "evopen/maligog",
"path": "/tests/rt_pipeline.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn render(&self) {
let index = self.swapchain.acquire_next_image().unwrap();
let present_img = self.swapchain.get_image(index);
let mut cmd_buf = self.device.create_command_buffer(
Some("main cmdbuf"),
self.device.graphics_queue_family_index(),
... | code_fim | hard | {
"lang": "rust",
"repo": "evopen/maligog",
"path": "/tests/rt_pipeline.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evopen/maligog path: /tests/rt_pipeline.rs
use std::convert::TryInto;
use maligog::vk;
use maligog::BufferView;
use maligog::Device;
use maligog::ImageView;
use maplit::btreemap;
use rayon::iter::IntoParallelRefIterator;
use rayon::iter::ParallelIterator;
use winit::platform::run_return::Event... | code_fim | hard | {
"lang": "rust",
"repo": "evopen/maligog",
"path": "/tests/rt_pipeline.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: himlpplm/rust-tdlib path: /src/types/upgrade_basic_group_chat_to_supergroup_chat.rs
use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
/// Creates a new supergroup from an existing basic group and sends a corresponding messageChatUpgradeTo and messageChatUpgradeFrom; requires creator pr... | code_fim | hard | {
"lang": "rust",
"repo": "himlpplm/rust-tdlib",
"path": "/src/types/upgrade_basic_group_chat_to_supergroup_chat.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[doc(hidden)]
pub struct RTDUpgradeBasicGroupChatToSupergroupChatBuilder {
inner: UpgradeBasicGroupChatToSupergroupChat,
}
impl RTDUpgradeBasicGroupChatToSupergroupChatBuilder {
pub fn build(&self) -> UpgradeBasicGroupChatToSupergroupChat {
self.inner.clone()
}
pub fn chat_id(&m... | code_fim | hard | {
"lang": "rust",
"repo": "himlpplm/rust-tdlib",
"path": "/src/types/upgrade_basic_group_chat_to_supergroup_chat.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AsRef<UpgradeBasicGroupChatToSupergroupChat> for UpgradeBasicGroupChatToSupergroupChat {
fn as_ref(&self) -> &UpgradeBasicGroupChatToSupergroupChat {
self
}
}
impl AsRef<UpgradeBasicGroupChatToSupergroupChat>
for RTDUpgradeBasicGroupChatToSupergroupChatBuilder
{
fn as_ref(&se... | code_fim | hard | {
"lang": "rust",
"repo": "himlpplm/rust-tdlib",
"path": "/src/types/upgrade_basic_group_chat_to_supergroup_chat.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: huonw/primal path: /primal-check/src/is_prime.rs
fn mod_mul_(a: u64, b: u64, m: u64) -> u64 {
(u128::from(a) * u128::from(b) % u128::from(m)) as u64
}
fn mod_mul(a: u64, b: u64, m: u64) -> u64 {
match a.checked_mul(b) {
Some(r) => if r >= m { r % m } else { r },
None => ... | code_fim | hard | {
"lang": "rust",
"repo": "huonw/primal",
"path": "/primal-check/src/is_prime.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const LIMIT: usize = 1_000_000;
let sieve = Sieve::new(LIMIT);
for x in 0..LIMIT {
let s = sieve.is_prime(x);
let mr = super::miller_rabin(x as u64);
assert!(s == mr, "miller_rabin {} mismatches sieve {} for {}",
mr, s, x)
... | code_fim | hard | {
"lang": "rust",
"repo": "huonw/primal",
"path": "/primal-check/src/is_prime.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// next will call recv on the inner UDP server (this blocks)
/// and will call from_packet from the given T
pub fn next(&self) -> Result<T, Box<dyn std::error::Error>> {
let packet = self.srv.recv()?;
T::from_packet(&packet)
}
}
/// AsyncTelemetryServer implements a gener... | code_fim | hard | {
"lang": "rust",
"repo": "ozkar99/cm-telemetry",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ozkar99/cm-telemetry path: /src/lib.rs
mod net;
pub mod dirt;
pub mod f1;
/// TelemetryPacket is an alias for a vector of bytes
pub type TelemetryPacket = [u8];
/// TelemetryEvent specifies a way to serialize itself from a Packet
pub trait TelemetryEvent {
fn from_packet(packet: &Telemetr... | code_fim | hard | {
"lang": "rust",
"repo": "ozkar99/cm-telemetry",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tokio-stream/src/stream_ext/timeout.rs
use
crate
:
:
stream_ext
:
:
Fuse
;
use
crate
:
:
Stream
;
use
tokio
:
:
time
:
:
{
Instant
Sleep
}
;
use
core
:
:
future
:
:
Future
;
use
core
:
:
pin
:
:
Pin
;
use
core
:
:
task
:
:
{
Context
Poll
}
;
us... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio-stream/src/stream_ext/timeout.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
.
duration
;
me
.
deadline
.
reset
(
next
)
;
*
me
.
poll_deadline
=
true
;
}
return
Poll
:
:
Ready
(
v
.
map
(
Ok
)
)
;
}
Poll
:
:
Pending
=
>
{
}
}
;
if
*
me
.
poll_deadline
{
ready
!
(
me
.
deadline
.
poll
(
cx
)
)
;
*
me
.
poll_deadline
=
false
;
return
Poll
:
:
Ready
(
Some
(
Err
(
Elapsed
:
:
new
(... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio-stream/src/stream_ext/timeout.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>unction
to
enable
use
of
question
mark
operator
.
fn
twice_plus_one
(
value
:
Option
<
usize
>
)
-
>
Option
<
usize
>
{
value
?
.
checked_mul
(
2
)
?
.
checked_add
(
1
)
}
(
lower
twice_plus_one
(
upper
)
)
}
}
/
/
=
=
=
=
=
impl
Elapsed
=
=
=
=
=
impl
Elapsed
{
pub
(
crate
)
fn
new
(
)
-
>
Self
{
Elapsed... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio-stream/src/stream_ext/timeout.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> // This module uses a broadcast channel instead of an mpsc channel, even
// though there's a single consumer of inventory advertisements, because
// the broadcast channel has ring-buffer behavior: when the channel is
// full, sending a new message displaces the oldest messa... | code_fim | hard | {
"lang": "rust",
"repo": "feifeivv/zebra",
"path": "/zebra-network/src/peer_set/inventory_registry.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: feifeivv/zebra path: /zebra-network/src/peer_set/inventory_registry.rs
//! Inventory Registry Implementation
//!
//! [RFC]: https://zebra.zfnd.org/dev/rfcs/0003-inventory-tracking.html
use std::{
collections::{HashMap, HashSet},
net::SocketAddr,
pin::Pin,
task::{Context, Poll},
... | code_fim | hard | {
"lang": "rust",
"repo": "feifeivv/zebra",
"path": "/zebra-network/src/peer_set/inventory_registry.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: antsant/adventofcode2020 path: /day_6_custom_customs/src/main.rs
use std::io;
use std::collections::HashMap;
fn main() {
let mut group_answers = HashMap::new();
let mut answer_count = 0;
<|fim_suffix|> println!("Answer: {}", answer_count);
}
fn count_answers(group_answers: &HashMap<char,... | code_fim | hard | {
"lang": "rust",
"repo": "antsant/adventofcode2020",
"path": "/day_6_custom_customs/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Answer: {}", answer_count);
}
fn count_answers(group_answers: &HashMap<char, bool>) -> u32 {
let mut count = 0;
for (_, _) in group_answers {
count += 1;
}
count
}<|fim_prefix|>// repo: antsant/adventofcode2020 path: /day_6_custom_customs/src/main.rs
use std::io;
use std::collections... | code_fim | hard | {
"lang": "rust",
"repo": "antsant/adventofcode2020",
"path": "/day_6_custom_customs/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> if line == "" {
answer_count += count_answers(&group_answers);
group_answers = HashMap::new();
} else {
for c in line.chars() {
group_answers.insert(c, true);
}
}
}
println!("Answer: {}", answer_count);
}
fn count_answers(group_answers: &HashMap<char, bool>) -> u32 {
let m... | code_fim | medium | {
"lang": "rust",
"repo": "antsant/adventofcode2020",
"path": "/day_6_custom_customs/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> // lookup value
let req_value = match args.get("value") {
Some(some_value) => match from_value::<String>(some_value.clone()) {
Ok(value) => Some(value),
Err(_) => None,
},
None => None,
};
if let Some(name... | code_fim | hard | {
"lang": "rust",
"repo": "infinyon/flv-kf-protocol",
"path": "/kf-protocol-build/src/format_code.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: infinyon/flv-kf-protocol path: /kf-protocol-build/src/format_code.rs
//!
//! # Format code based son Jinja2 templates
//!
use std::fs::metadata;
use std::io::Error as IoError;
use std::io::ErrorKind;
use std::path::Path;
use std::str;
use serde_json;
use serde_json::value::{from_value, to_valu... | code_fim | hard | {
"lang": "rust",
"repo": "infinyon/flv-kf-protocol",
"path": "/kf-protocol-build/src/format_code.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Goirad/Quadtree path: /benches/benches.rs
#![feature(test)]
extern crate test;
extern crate rand;
extern crate quadtree;
use quadtree::{Boundable, BoundingBox, Quadtree};
#[derive(Debug)]
struct Point {
x: f64,
y: f64,
}
impl Boundable for Point {
fn bounds(&self) -> BoundingBox {... | code_fim | hard | {
"lang": "rust",
"repo": "Goirad/Quadtree",
"path": "/benches/benches.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bb = BoundingBox {
x: 0.0,
y: 0.0,
w: 50.0,
h: 50.0,
};
let mut rng = StdRng::from_seed(&[24, 25, 12]);
let mut pts = vec![];
let mut qt: Quadtree<Point> = Quadtree::new(bb, 10);
for _ in 0..1_000 {
... | code_fim | hard | {
"lang": "rust",
"repo": "Goirad/Quadtree",
"path": "/benches/benches.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[bench]
fn find_100_000(b: &mut Bencher) {
let bb = BoundingBox {
x: 0.0,
y: 0.0,
w: 50.0,
h: 50.0,
};
let mut rng = StdRng::from_seed(&[24, 25, 12]);
let mut pts = vec![];
let mut qt: Quadtree<Point> = Quadtr... | code_fim | hard | {
"lang": "rust",
"repo": "Goirad/Quadtree",
"path": "/benches/benches.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nitrokey/nitrokey-3-firmware path: /runners/embedded/src/soc_nrf52840/board_proto1.rs
use nrf52840_hal::{
gpio::{p0, p1, Level},
gpiote::Gpiote,
spim,
};
use crate::soc::types::BoardGPIO;
pub type TrussedUI = super::dummy_ui::DummyUI;
pub const BOARD_NAME: &'static str = "Proto1";... | code_fim | hard | {
"lang": "rust",
"repo": "Nitrokey/nitrokey-3-firmware",
"path": "/runners/embedded/src/soc_nrf52840/board_proto1.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let flashnfc_spi = spim::Pins {
sck: flashnfc_spi_clk,
miso: Some(flashnfc_spi_miso),
mosi: Some(flashnfc_spi_mosi),
};
BoardGPIO {
buttons: [
Some(btn1),
Some(btn2),
Some(btn3),
None,
None,
... | code_fim | hard | {
"lang": "rust",
"repo": "Nitrokey/nitrokey-3-firmware",
"path": "/runners/embedded/src/soc_nrf52840/board_proto1.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndreMouche/rust path: /http_server_sample/src/main.rs
extern crate hyper;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate prometheus;
extern crate random;
use hyper::server::{Request, Response, Server};
use std::io::Write;
use prometheus::{Counter,CounterVec, Encoder, Gauge, ... | code_fim | hard | {
"lang": "rust",
"repo": "AndreMouche/rust",
"path": "/http_server_sample/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let encoder = TextEncoder::new();
let mut buffer = vec![];
let metric_families = prometheus::gather();
encoder.encode(&metric_families, &mut buffer).unwrap();
buffer
}
fn get_request_message(req:&Request)->Vec<u8> {
let mut buffer = vec![];
writeln!(&mut buffer,"Welcome... | code_fim | hard | {
"lang": "rust",
"repo": "AndreMouche/rust",
"path": "/http_server_sample/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if timer.is_none(){
return;
}
timer.unwrap().observe_duration();
HTTP_BODY_GAUGE.set(content_len as f64);
}
fn main() {
println!("listening addr {:?}", ADDR);
let enable_prometheus = true;
Server::http(ADDR)
.unwrap()
.handle(move |req: Request, r... | code_fim | hard | {
"lang": "rust",
"repo": "AndreMouche/rust",
"path": "/http_server_sample/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: panther-king/dogrun path: /src/lib.rs
//! # dogrun
//!
//! The dog eats everthing.
use std::collections::BTreeMap;
use std::fmt;
use std::fs;
use std::io::ErrorKind;
use std::path::Path;
use self::DogError::*;
use self::TastingError::*;
pub type BadFood = BTreeMap<String, TastingError>;
pub ty... | code_fim | hard | {
"lang": "rust",
"repo": "panther-king/dogrun",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut foods = BTreeMap::new();
for food in self.foods.iter() {
let path = Path::new(&food);
match self.taste(&path) {
Ok(_) => continue,
Err(e) => foods.insert(food.clone(), e),
};
}
foods
}
}
#[cfg... | code_fim | hard | {
"lang": "rust",
"repo": "panther-king/dogrun",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: keks/oasis-core path: /runtime-loader/src/elf.rs
//! ELF runtime loader.
use std::process::Command;
use failure::{format_err, Fallible};
<|fim_suffix|>/// ELF runtime loader.
pub struct ElfLoader;
impl Loader for ElfLoader {
fn run(
&self,
filename: String,
_signat... | code_fim | medium | {
"lang": "rust",
"repo": "keks/oasis-core",
"path": "/runtime-loader/src/elf.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Loader for ElfLoader {
fn run(
&self,
filename: String,
_signature_filename: Option<&str>,
host_socket: String,
) -> Fallible<()> {
Command::new(filename)
.env("OASIS_WORKER_HOST", host_socket)
.spawn()?
.wait()
... | code_fim | medium | {
"lang": "rust",
"repo": "keks/oasis-core",
"path": "/runtime-loader/src/elf.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(index) = symbol_table_stack.top() {
node_index = index;
} else {
error(14);
unimplemented!()
}
if global_table_graph.is_node_record(node_index) {
// variable/function declaration
let node = global_table_graph.get_node_mut(node_index).unw... | code_fim | hard | {
"lang": "rust",
"repo": "lancelafontaine/crs-compiler",
"path": "/src/semantic/symbol_table_visitor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lancelafontaine/crs-compiler path: /src/semantic/symbol_table_visitor.rs
use ast::{AstNode, SemanticActionType};
use semantic::symbol_table::{STRecordType, GENERATED_SYMBOL_TABLE_GRAPH};
use std::collections::HashMap;
use std::sync::Mutex;
use util::Stack;
use output::{ error, write_to_symbol_ta... | code_fim | hard | {
"lang": "rust",
"repo": "lancelafontaine/crs-compiler",
"path": "/src/semantic/symbol_table_visitor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if global_table_graph.is_node_record(node_index) {
// variable/function declaration
let node = global_table_graph.get_node_mut(node_index).unwrap();
if node.get_record_identifier().is_some() {
// Previously set identifier was actually a class type!
let c... | code_fim | hard | {
"lang": "rust",
"repo": "lancelafontaine/crs-compiler",
"path": "/src/semantic/symbol_table_visitor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let mut test = X(box 5);
{
let mut change = || { *test = 10 };
change();
}
assert_eq!(*test, 10);
}
assert!(unsafe { DESTRUCTOR_RAN });
}<|fim_prefix|>// repo: moshg/rust-std-ja path: /src/test/run-pass/issue-16774.rs
// Copyright 2014... | code_fim | medium | {
"lang": "rust",
"repo": "moshg/rust-std-ja",
"path": "/src/test/run-pass/issue-16774.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: moshg/rust-std-ja path: /src/test/run-pass/issue-16774.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// ... | code_fim | medium | {
"lang": "rust",
"repo": "moshg/rust-std-ja",
"path": "/src/test/run-pass/issue-16774.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: albhaf/trampoline path: /build.rs
use std::process::Command;
use std::env;
use std::path::Path;
<|fim_suffix|> Command::new("as")
.args(&["src/x86_64.S", "-fPIC", "-o"])
.arg(&format!("{}/trampoline.o", out_dir))
.status()
.unwrap();
Command::new("ar")
... | code_fim | medium | {
"lang": "rust",
"repo": "albhaf/trampoline",
"path": "/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=static=trampoline");
}<|fim_prefix|>// repo: albhaf/trampoline path: /build.rs
use std::process::Command;
use std::env;
use std::path::Path;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "albhaf/trampoline",
"path": "/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Krishnacore/move-tools path: /dove/src/cmd/mod.rs
use std::path::PathBuf;
use anyhow::{Error, Result};
use semver::{Version, VersionReq};
use crate::context::{Context, get_context, load_manifest};
/// Project builder.
pub mod build;
/// Project dependencies loader.
pub mod clean;
/// Documenta... | code_fim | hard | {
"lang": "rust",
"repo": "Krishnacore/move-tools",
"path": "/dove/src/cmd/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Functions create execution context and apply command with it.
fn execute(self, project_dir: PathBuf) -> Result<()>
where
Self: std::marker::Sized,
{
let context = self.context(project_dir)?;
self.apply(context)
}
}
fn check_dove_version(req_ver: &str, act_v... | code_fim | hard | {
"lang": "rust",
"repo": "Krishnacore/move-tools",
"path": "/dove/src/cmd/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>CAN_CONTINUE | OpcodeFlags::SETS_REGISTER"
)]
SubInt,
#[enum_values(
value = "0x92",
name = "mul-int",
reference_type = "ReferenceType::None",
format = "Format::Format23x",
flags = "OpcodeFlags::CAN_CONTINUE | OpcodeFlags::SETS_REGISTER"
)]
MulInt,
#[enum_values(
value = "0x93",
name =... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/smali",
"path": "/src/dex/asm/opcode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForsakenHarmony/smali path: /src/dex/asm/opcode.rs
NUE"
)]
IfGez,
#[enum_values(
value = "0x3c",
name = "if-gtz",
reference_type = "ReferenceType::None",
format = "Format::Format21t",
flags = "OpcodeFlags::CAN_CONTINUE"
)]
IfGtz,
#[enum_values(
value = "0x3d",
name = "if-lez"... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/smali",
"path": "/src/dex/asm/opcode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForsakenHarmony/smali path: /src/dex/asm/opcode.rs
renceType::None",
format = "Format::Format22t",
flags = "OpcodeFlags::CAN_CONTINUE"
)]
IfNe,
#[enum_values(
value = "0x34",
name = "if-lt",
reference_type = "ReferenceType::None",
format = "Format::Format22t",
flags = "OpcodeFla... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/smali",
"path": "/src/dex/asm/opcode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: linkenneth/project-euler path: /3/3.rs
use std::collections::HashSet;
fn primes(x: u64) -> HashSet<u64> {
<|fim_suffix|> let x = 600851475143;
println!("{:#?}", primes(x).iter().max());
}<|fim_middle|> let root = (x as f64).sqrt() as u64 + 1;
let mut results = HashSet::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "linkenneth/project-euler",
"path": "/3/3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let x = 600851475143;
println!("{:#?}", primes(x).iter().max());
}<|fim_prefix|>// repo: linkenneth/project-euler path: /3/3.rs
use std::collections::HashSet;
fn primes(x: u64) -> HashSet<u64> {
<|fim_middle|> let root = (x as f64).sqrt() as u64 + 1;
let mut results = HashSet:... | code_fim | hard | {
"lang": "rust",
"repo": "linkenneth/project-euler",
"path": "/3/3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[pymodule]
fn locustdb(_py: Python, m: &PyModule) -> PyResult<()> {
env_logger::init();
m.add_function(wrap_pyfunction!(log, m)?).unwrap();
Ok(())
}
#[pyfunction]
fn log(table: &str, metrics: HashMap<String, i64>) -> PyResult<()> {
let mut client = DEFAULT_CLIENT.lock().unwrap();
cli... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/LocustDB",
"path": "/src/python.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/LocustDB path: /src/python.rs
#![allow(clippy::too_many_arguments)]
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use pyo3::{prelude::*, wrap_pyfunction};
use crate::logging_client::LoggingClient;
lazy_static! {
static ref RT: tokio::runtime::Runtime = tokio::ru... | code_fim | medium | {
"lang": "rust",
"repo": "SINHASantos/LocustDB",
"path": "/src/python.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustCrypto/traits path: /aead/src/lib.rs
ciphertexts are authentic
pub type Tag<A> = GenericArray<u8, <A as AeadCore>::TagSize>;
/// Authenticated Encryption with Associated Data (AEAD) algorithm core trait.
///
/// Defines nonce, tag, and overhead sizes that are consumed by various other
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/traits",
"path": "/aead/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustCrypto/traits path: /aead/src/lib.rs
oth confidentiality and integrity, even from a powerful attacker who is
//! able to execute [chosen-ciphertext attacks]. The resulting security property,
//! [ciphertext indistinguishability], is considered a basic requirement for
//! modern cryptographic... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/traits",
"path": "/aead/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tag_pos = $buffer.len() - Self::TagSize::to_usize();
let (msg, tag) = $buffer.as_mut().split_at_mut(tag_pos);
$aead.decrypt_in_place_detached($nonce, $aad, msg, Tag::<Self>::from_slice(tag))?;
$buffer.truncate(tag_pos);
Ok(())
}};
}
/// In-place stateless A... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/traits",
"path": "/aead/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dinfuehr/dora path: /dora-language-server/src/symbols.rs
use std::sync::Arc;
use dora_parser::ast::visit::Visitor;
use lsp_server::{Message, Request, Response};
use lsp_types::{DocumentSymbol, DocumentSymbolResponse, Position, Range, SymbolKind};
use dora_parser::ast::{self, visit};
use dora_p... | code_fim | hard | {
"lang": "rust",
"repo": "dinfuehr/dora",
"path": "/dora-language-server/src/symbols.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ref type_params) = node.type_params {
let span = type_params.span;
let type_params_string =
&self.content.as_str()[span.start() as usize..span.end() as usize];
name.push_str(type_params_string);
}
if let Some(ref trai... | code_fim | hard | {
"lang": "rust",
"repo": "dinfuehr/dora",
"path": "/dora-language-server/src/symbols.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcls/svd2rust-example path: /stm32l051x/src/flash/acr.rs
#[doc = "Register `ACR` reader"]
pub struct R(crate::R<ACR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<ACR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<... | code_fim | hard | {
"lang": "rust",
"repo": "rcls/svd2rust-example",
"path": "/stm32l051x/src/flash/acr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `PRE_READ` writer - Pre-read data address"]
pub struct PRE_READ_W<'a> {
w: &'a mut W,
}
impl<'a> PRE_READ_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears th... | code_fim | hard | {
"lang": "rust",
"repo": "rcls/svd2rust-example",
"path": "/stm32l051x/src/flash/acr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `RUN_PD` writer - Flash mode during Run"]
pub struct RUN_PD_W<'a> {
w: &'a mut W,
}
impl<'a> RUN_PD_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the fiel... | code_fim | hard | {
"lang": "rust",
"repo": "rcls/svd2rust-example",
"path": "/stm32l051x/src/flash/acr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn carve_passages_from<R: Rng + ?Sized>(c: Pos, maze: &mut RazorMaze, rng: &mut R) {
let mut directions = [Dir::N, Dir::E, Dir::S, Dir::W];
rng.shuffle(&mut directions);
for dir in directions.into_iter() {
let n = c + d(*dir);
if maze.contains(n) && maze[n] == 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "stpyramids/stpyr",
"path": "/stpyr/src/labyrinth.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: TilePicker> TileGenerator for RecursiveBacktracking<T> {
fn generate(&self, current: &Grid<Tile>, bounds: Bounds) -> Result<Vec<(Pos, Tile)>, GenError> {
let (start, end) = bounds;
let (width, height) = ((end.0 - start.0), (end.1 - start.1));
if width < 6 || height < 6 ... | code_fim | hard | {
"lang": "rust",
"repo": "stpyramids/stpyr",
"path": "/stpyr/src/labyrinth.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stpyramids/stpyr path: /stpyr/src/labyrinth.rs
pub use crate::tile_generator::*;
use rand::prelude::*;
pub mod mazes {
use super::*;
pub fn recursive_backtracking<T: TilePicker>(picker: T) -> impl TileGenerator {
super::RecursiveBacktracking(picker)
}
}
#[derive(Debug)]
st... | code_fim | hard | {
"lang": "rust",
"repo": "stpyramids/stpyr",
"path": "/stpyr/src/labyrinth.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: upenn-cis198/final-project-idk path: /keylogger/src/main.rs
#[macro_use]
extern crate lazy_static;
extern crate chrono;
extern crate regex;
extern crate libc;
use regex::Regex;
use std::io::{self, Read};
use std::fs::File;
use std::mem;
mod keys;
mod events;
mod parser;
mod notification;
fn m... | code_fim | hard | {
"lang": "rust",
"repo": "upenn-cis198/final-project-idk",
"path": "/keylogger/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
}
// function gets device
fn get_device_file() -> Result<String, io::Error> {
let mut file = File::open("/proc/bus/input/devices")?;
let mut s = String::new();
file.read_to_string(&mut s)?;
// we get our device through regex
let expression = Regex::new("((.*\n){2})(B: EV=120013)").... | code_fim | hard | {
"lang": "rust",
"repo": "upenn-cis198/final-project-idk",
"path": "/keylogger/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> draw_text(
"H for help",
screen_width() - 135.0,
20.0,
25.0,
Color::from_rgba(216, 222, 233, 180),
);
}
next_frame().await
}
}
fn show_help(help_controls: &[&'static str]) {
dra... | code_fim | hard | {
"lang": "rust",
"repo": "v1nam/travelling_salesman",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: v1nam/travelling_salesman path: /src/main.rs
use macroquad::prelude::*;
mod aco;
use aco::Colony;
fn window_conf() -> Conf {
Conf {
window_title: "Travelling Salesman".to_owned(),
window_width: 1000,
window_height: 700,
..Default::default()
}
}
#[macroq... | code_fim | hard | {
"lang": "rust",
"repo": "v1nam/travelling_salesman",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gzbakku/fdb path: /store/store/src/engine/write/process/define.rs
use crate::engine::write::parse::Collection;
pub enum WriteResult {
Error(ERROR),
Success(SUCCESS)
}
pub struct SUCCESS{
pub collection:String
}
<|fim_suffix|>impl ERROR {
pub fn new(c:Collection,e:String) -> ER... | code_fim | hard | {
"lang": "rust",
"repo": "gzbakku/fdb",
"path": "/store/store/src/engine/write/process/define.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct ERROR{
pub collection:String,
pub error:String
}
impl ERROR {
pub fn new(c:Collection,e:String) -> ERROR {
ERROR {
collection:c.cuid.clone(),
error:e
}
}
pub fn new_str(c:Collection,e:&str) -> ERROR {
ERROR {
colle... | code_fim | medium | {
"lang": "rust",
"repo": "gzbakku/fdb",
"path": "/store/store/src/engine/write/process/define.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xiuxiu62/engine-q path: /crates/nu-engine/src/lib.rs
mod call_ext;
mod documentation;
mod eval;
mod from_value;
pub us<|fim_suffix|>ck, eval_expression, eval_operator};
pub use from_value::FromValue;<|fim_middle|>e call_ext::CallExt;
pub use documentation::{generate_docs, get_brief_help, get_do... | code_fim | medium | {
"lang": "rust",
"repo": "xiuxiu62/engine-q",
"path": "/crates/nu-engine/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ck, eval_expression, eval_operator};
pub use from_value::FromValue;<|fim_prefix|>// repo: xiuxiu62/engine-q path: /crates/nu-engine/src/lib.rs
mod call_ext;
mod documentation;
mod eval;
mod from_value;
pub use call_ext::CallExt;
pub use documentation::{generate_docs, get_bri<|fim_middle|>ef_help, get_do... | code_fim | medium | {
"lang": "rust",
"repo": "xiuxiu62/engine-q",
"path": "/crates/nu-engine/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hooops/crypto-crawler-rs path: /crypto-contract-value/src/exchanges/bitget.rs
use crypto_market_type::MarketType;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashMap};
use super::utils::http_get;
lazy_static! {
static ref LINEAR_SWAP_... | code_fim | hard | {
"lang": "rust",
"repo": "hooops/crypto-crawler-rs",
"path": "/crypto-contract-value/src/exchanges/bitget.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> mapping
}
pub(crate) fn get_contract_value(market_type: MarketType, pair: &str) -> Option<f64> {
match market_type {
MarketType::InverseSwap => Some(1.0),
MarketType::LinearSwap => Some(LINEAR_SWAP_CONTRACT_VALUES[pair]),
_ => None,
}
}
#[cfg(test)]
mod tests {
us... | code_fim | hard | {
"lang": "rust",
"repo": "hooops/crypto-crawler-rs",
"path": "/crypto-contract-value/src/exchanges/bitget.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brianbruggeman/leis-municipais path: /tests/integration.rs
use assert_cmd::Command;
use predicates::prelude::*;
use std::fs;
#[test]
fn should_parser_folder_and_write_leis_to_file_as_json() {
let mut cmd = Command::cargo_bin("leis-municipais").unwrap();
let file_name = "leis_em_json.jso... | code_fim | hard | {
"lang": "rust",
"repo": "brianbruggeman/leis-municipais",
"path": "/tests/integration.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cmd = Command::cargo_bin("leis-municipais").unwrap();
let file_name = "leis_em_json.anything";
cmd.arg("resources/integration_tests/leis");
cmd.arg(file_name);
cmd.assert().stdout(predicate::str::contains(
"Nome de arquivo não permitido. Extensão do arquivo deve ser .j... | code_fim | hard | {
"lang": "rust",
"repo": "brianbruggeman/leis-municipais",
"path": "/tests/integration.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thulyatech/tantivy path: /fastfield_codecs/src/blockwise_linear.rs
use std::sync::Arc;
use std::{io, iter};
use common::{BinarySerializable, CountingWriter, DeserializeFrom, OwnedBytes};
use tantivy_bitpacker::{compute_num_bits, BitPacker, BitUnpacker};
use crate::line::Line;
use crate::serial... | code_fim | hard | {
"lang": "rust",
"repo": "thulyatech/tantivy",
"path": "/fastfield_codecs/src/blockwise_linear.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (num_vals as usize + CHUNK_SIZE - 1) / CHUNK_SIZE
}
pub struct BlockwiseLinearCodec;
impl FastFieldCodec for BlockwiseLinearCodec {
const CODEC_TYPE: crate::FastFieldCodecType = FastFieldCodecType::BlockwiseLinear;
type Reader = BlockwiseLinearReader;
fn open_from_bytes(
bytes: ... | code_fim | hard | {
"lang": "rust",
"repo": "thulyatech/tantivy",
"path": "/fastfield_codecs/src/blockwise_linear.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for WideString {
fn from(s: &'a T) -> Self {
WideString {
chars: s.as_ref().encode_wide()
.chain(std::iter::once(0))
.collect()
}
}
}
impl WideString {
pub fn as_ptr(&self) -> *const WCH... | code_fim | easy | {
"lang": "rust",
"repo": "azyobuzin/rust-live2dd3d11",
"path": "/d3dappbase/src/wide_string.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azyobuzin/rust-live2dd3d11 path: /d3dappbase/src/wide_string.rs
use std;
use std::ffi::OsStr;
use std::os::windows::prelude::*;
use winapi::WCHAR;
<|fim_suffix|>impl WideString {
pub fn as_ptr(&self) -> *const WCHAR {
self.chars.as_ptr()
}
}<|fim_middle|>pub struct WideString {
... | code_fim | hard | {
"lang": "rust",
"repo": "azyobuzin/rust-live2dd3d11",
"path": "/d3dappbase/src/wide_string.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<P> AsyncReadAll for CacheService<P>
where
P: Protocol,
{
#[inline]
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<Response>> {
Pin::new(&mut self.inner).poll_next(cx)
}
}
impl<P> AsyncWriteAll for CacheService<P>
where
P: Protocol,
{
// 支持pipe... | code_fim | hard | {
"lang": "rust",
"repo": "Aimable-rich/breeze",
"path": "/endpoint/src/cacheservice/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Aimable-rich/breeze path: /endpoint/src/cacheservice/mod.rs
mod config;
mod topology;
use config::Namespace;
pub use topology::Topology;
use discovery::ServiceDiscover;
use stream::backend::AddressEnable;
use hash::Hasher;
use stream::{
AsyncGetSync, AsyncMultiGet, AsyncMultiGetSharding, ... | code_fim | hard | {
"lang": "rust",
"repo": "Aimable-rich/breeze",
"path": "/endpoint/src/cacheservice/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>st_use]
pub fn reg11en(&mut self) -> REG11EN_W<PWR_CR3_SPEC, 30> {
REG11EN_W::new(self)
}
#[doc = "Writes raw bits to the register."]
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.bits = bits;
self
}
}
#[doc = "Not reset by w... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32mp1/src/stm32mp153/pwr/pwr_cr3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp153/pwr/pwr_cr3.rs
#[doc = "Register `PWR_CR3` reader"]
pub type R = crate::R<PWR_CR3_SPEC>;
#[doc = "Register `PWR_CR3` writer"]
pub type W = crate::W<PWR_CR3_SPEC>;
#[doc = "Field `VBE` reader - VBE"]
pub type VBE_R = crate::BitReader;
#[d... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32mp1/src/stm32mp153/pwr/pwr_cr3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 5l1v3r1/myodine path: /src/client/main.rs
extern crate chrono;
extern crate clap;
extern crate myodine;
mod flags;
mod logger;
mod discovery;
mod establish;
mod session;
use std::net::{TcpListener, TcpStream};
use std::process::exit;
use std::thread::spawn;
use flags::Flags;
use logger::RawLo... | code_fim | hard | {
"lang": "rust",
"repo": "5l1v3r1/myodine",
"path": "/src/client/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Err(msg) = main_or_err() {
eprintln!("{}", msg);
exit(1);
}
}
fn main_or_err() -> Result<(), String> {
let flags = Flags::parse()?;
let listener = TcpListener::bind(&format!("localhost:{}", flags.listen_port)).
map_err(|e| format!("listen error: {}", e))?;
... | code_fim | medium | {
"lang": "rust",
"repo": "5l1v3r1/myodine",
"path": "/src/client/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger.log(format!("discovering features @{} for {}...", flags.host, flags.addr));
let features = discover_features(&flags)
.map_err(|e| format!("failed to discover features: {}", e))?;
logger.log("establishing session...".to_owned());
let establishment = establish(&flags, features... | code_fim | hard | {
"lang": "rust",
"repo": "5l1v3r1/myodine",
"path": "/src/client/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsround/av/icon_new_releases.rs
pub struct IconNewReleases {
props: crate::Props,
}
impl yew::Component for IconNewReleases {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew::prelud... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconsround/av/icon_new_releases.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>*/
use std::f64::consts::*;
fn main() {
test(26.0, 1000.0, 5.0, 1.29, 928.20);
test(27.25, 873234.0, 3000.0, 1179.86, 1415.84);
}
fn test(diameter: f64, revolutions: f64, time: f64, expected_distance: f64, expected_speed: f64) {
let eps = 1e-2;
let (distance, speed) = motion(diameter, r... | code_fim | hard | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/poj/1665-bikers-trip-odometer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qeedquan/challenges path: /poj/1665-bikers-trip-odometer.rs
/*
Description
Most bicycle speedometers work by using a Hall Effect sensor fastened to the front fork of the bicycle. A magnet is attached to one of the spokes on the front wheel so that it will line up with the Hall Effect switch on... | code_fim | medium | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/poj/1665-bikers-trip-odometer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Greater New York 2003
*/
use std::f64::consts::*;
fn main() {
test(26.0, 1000.0, 5.0, 1.29, 928.20);
test(27.25, 873234.0, 3000.0, 1179.86, 1415.84);
}
fn test(diameter: f64, revolutions: f64, time: f64, expected_distance: f64, expected_speed: f64) {
let eps = 1e-2;
let (distance, spee... | code_fim | hard | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/poj/1665-bikers-trip-odometer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>peration;
mod parser;
mod sp_assignment;<|fim_prefix|>// repo: endre90/micro_sp path: /src/tests/mod.rs
mod predicate;
mod state;
mod sp_value;
mod sp_variable;
mod sp_wrapped;
mod act<|fim_middle|>ion;
mod transition;
mod planning;
mod o | code_fim | easy | {
"lang": "rust",
"repo": "endre90/micro_sp",
"path": "/src/tests/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: endre90/micro_sp path: /src/tests/mod.rs
mod predicate;
mod state;
mod sp_value;
<|fim_suffix|>ion;
mod transition;
mod planning;
mod operation;
mod parser;
mod sp_assignment;<|fim_middle|>mod sp_variable;
mod sp_wrapped;
mod act | code_fim | easy | {
"lang": "rust",
"repo": "endre90/micro_sp",
"path": "/src/tests/mod.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.