text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>/// Desired range of eigenvalues.
#[derive(Clone, Debug)]
pub enum EigenvalueRange<T> {
All,
/// Half-open range of desired eigenvalues.
Values(Range<T>),
/// 1-indexed indices of the desired eigenvalues in ascending order.
Indices(RangeInclusive<i32>),
}
impl<T> Default for Eigenvalu... | code_fim | hard | {
"lang": "rust",
"repo": "xrf/lutario",
"path": "/src/linalg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> message.push_str(&format!("Number of nodes: {} | Type: {}\n",
self.heap_size, self.kind));
for i in 0..(lowest_parent + 1) {
// #..=# is slower than #..# bc the former is not compiler optimized
// loop unrolling is not performed for the former...
... | code_fim | hard | {
"lang": "rust",
"repo": "CosmicSyntax/minmaxheap",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CosmicSyntax/minmaxheap path: /src/lib.rs
//! # Binary Heap
//! This crate implements both min and max binary heaps.
//! # Quick Start
//! ```rust
//! use minmaxheap::Heap;
//!
//! // Instantiate a Heap
//! let mut heap = Heap::new("max", 10).expect("Something did not work");
//!
//! // Add dat... | code_fim | hard | {
"lang": "rust",
"repo": "CosmicSyntax/minmaxheap",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let aspect = width as f32 / height as f32;
let max_y = (s.fovy / 2.0).tan();
let scale = 2.0 * max_y / height as f32;
let shift = -max_y;
let view_to_world = Matrix::from_cols(s.x(), s.y(), s.z());
for y in 0 .. height {
for x in 0 .. width {
// in view coordinates
let ray =
... | code_fim | hard | {
"lang": "rust",
"repo": "bfops/rust-raytrace",
"path": "/src/raytrace.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bfops/rust-raytrace path: /src/raytrace.rs
use rand;
use std;
use prelude::*;
use scene;
pub struct Output {
data : Vec<RGB>,
w : u32,
h : u32,
}
impl Output {
pub fn new(w: u32, h: u32) -> Self {
Output {
data : std::iter::repeat(RGB { r: 0.0, g: 0.0, b: 0.0 }).take((... | code_fim | hard | {
"lang": "rust",
"repo": "bfops/rust-raytrace",
"path": "/src/raytrace.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let collision =
match cast(s, &work.ray) {
None => return,
Some(c) => c,
};
let color =
match collision.object.texture {
scene::Texture::SolidColor(color) => color,
};
let color = work.attenuation * color;
*output.pixel_mut(work.pixel_x, work.pixel_y) += color *... | code_fim | hard | {
"lang": "rust",
"repo": "bfops/rust-raytrace",
"path": "/src/raytrace.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luke-biel/mafia path: /backend/src/routes/mod.rs
pub mod action;
pub mod admin;
pub mod capabilities;
pub mod events;
pub mod game_state;
pub mod register;
pub mod user;
<|fim_suffix|>pub const MAFIA_GUID_COOKIE_NAME: &str = "mafia-guid";
pub fn cors() -> Cors {
warp::cors()
.allow... | code_fim | hard | {
"lang": "rust",
"repo": "luke-biel/mafia",
"path": "/backend/src/routes/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn cors() -> Cors {
warp::cors()
.allow_any_origin()
.allow_credentials(true)
.allow_headers(vec![
"Referer",
"Content-Type",
"Authorization",
"Origin",
"Access-Control-Request-Method",
"Access-Control-... | code_fim | medium | {
"lang": "rust",
"repo": "luke-biel/mafia",
"path": "/backend/src/routes/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davidpdrsn/advent-of-code-2019 path: /src/day_4.rs
use super::{read_file, Error, Part, Result};
use crate::BoolThenExt;
use std::{collections::HashSet, ops::RangeBounds};
mod part_1;
mod part_2;
pub fn main(part: Part) -> Result<()> {
let input = (347312..=805915);
match part {
... | code_fim | hard | {
"lang": "rust",
"repo": "davidpdrsn/advent-of-code-2019",
"path": "/src/day_4.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn validate_each_digit_increases_test() {
assert!(validate_each_digit_increases(123).is_some(), "123");
assert!(validate_each_digit_increases(1233).is_some(), "1233");
assert!(validate_each_digit_increases(1232).is_none(), "1232");
}
#[test]
#[ignore]
fn validate_two_identical_adjacen... | code_fim | hard | {
"lang": "rust",
"repo": "davidpdrsn/advent-of-code-2019",
"path": "/src/day_4.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>.swap_remove(idx);
inventory.put_at(item.into(), at);
}
None => {}
}
}
}
GoEast => {
scene.enter_adjacent_room(CompassPoin... | code_fim | hard | {
"lang": "rust",
"repo": "hegza/roguelike-rs",
"path": "/src/game/handle_input/story/treasure.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hegza/roguelike-rs path: /src/game/handle_input/story/treasure.rs
use rpglib::*;
use game::handle_input::*;
use game::scenes::game_scene::*;
use game::scenes::game_scene::story_option::StoryOption::*;
pub fn handle_input(cmd: Command, scene: &mut GameScene) -> bool {
let options = scene.sto... | code_fim | hard | {
"lang": "rust",
"repo": "hegza/roguelike-rs",
"path": "/src/game/handle_input/story/treasure.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
use tokio::prelude::Async::*;
// TODO(mkl): rewrite this
match &mut self.handshake {
&mut None => {
let inner_poll = self.inner
.poll()
.map_err(|er... | code_fim | hard | {
"lang": "rust",
"repo": "alishahusain/lpd",
"path": "/connection/src/address/tcp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct TcpConnectionStream
{
inner: Box<dyn Stream<Item=TcpStream, Error=io::Error> + Send + Sync>,
handshake: Option<(Box<dyn Future<Item=BrontideStream<TcpStream>, Error=HandshakeError> + Send + 'static>, SocketAddr)>,
local_secret: SecretKey,
}
impl Stream for TcpConnectionStream {
... | code_fim | hard | {
"lang": "rust",
"repo": "alishahusain/lpd",
"path": "/connection/src/address/tcp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alishahusain/lpd path: /connection/src/address/tcp.rs
use dependencies::secp256k1;
use dependencies::tokio;
use super::AbstractAddress;
use std::{net::SocketAddr, io};
use secp256k1::{SecretKey, PublicKey};
use tokio::{
prelude::{Future, Stream, Poll},
net::{TcpStream, TcpListener, tcp... | code_fim | hard | {
"lang": "rust",
"repo": "alishahusain/lpd",
"path": "/connection/src/address/tcp.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn insert(&mut self, item: &str){
let new_id = BoxId::new(&item);
let sorted = new_id.sorted.clone();
let mut uniques = sorted.clone();
uniques.dedup();
let dupe_info = self.hashes.entry(new_id).or_insert((0, false, false)) ;
dupe_info.0 += 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "fweez/adventofcode",
"path": "/2018/2/boxids/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fweez/adventofcode path: /2018/2/boxids/src/lib.rs
use std::hash::{Hash, Hasher};
use std::collections::HashMap;
struct BoxId {
id: String,
sorted: Vec<char>
}
impl BoxId {
fn new(id: &str) -> BoxId {
let id = id.to_string();
let mut sorted: Vec<char> = id.chars().c... | code_fim | hard | {
"lang": "rust",
"repo": "fweez/adventofcode",
"path": "/2018/2/boxids/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen]
impl KDF {
/**
* Implementation of PBKDF2 - when None is specified for salt, a random salt will be generated
*/
pub fn pbkdf2(password: &[u8], salt: Option<Vec<u8>>, hash_algo: PBKDF2Hashes, rounds: u32, output_length: usize) -> KDF {
match salt {
Some... | code_fim | hard | {
"lang": "rust",
"repo": "wszhang/bsv-wasm",
"path": "/src/kdf/pbkdf2_kdf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wszhang/bsv-wasm path: /src/kdf/pbkdf2_kdf.rs
use crate::{hash::Hash, KDF};
use hmac::Hmac;
use pbkdf2::{
password_hash::{Ident, PasswordHasher, Salt, SaltString},
pbkdf2, Params, Pbkdf2,
};
use rand_core::OsRng;
use sha1::Sha1;
use sha2::{Sha256, Sha512};
use wasm_bindgen::prelude::*;
u... | code_fim | hard | {
"lang": "rust",
"repo": "wszhang/bsv-wasm",
"path": "/src/kdf/pbkdf2_kdf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Liby99/geometry-sketchpad path: /core/ui/src/resources/snap_circle.rs
use specs::prelude::*;
pub struct SnapCircle {
pub maybe_first_point: Option<Entity>,
}
<|fim_suffix|> Self {
maybe_first_point: None,
}
}
}<|fim_middle|>impl Default for SnapCircle {
fn default() -> Self ... | code_fim | easy | {
"lang": "rust",
"repo": "Liby99/geometry-sketchpad",
"path": "/core/ui/src/resources/snap_circle.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
maybe_first_point: None,
}
}
}<|fim_prefix|>// repo: Liby99/geometry-sketchpad path: /core/ui/src/resources/snap_circle.rs
use specs::prelude::*;
pub struct SnapCircle {
pub maybe_first_point: Option<Entity>,
}
<|fim_middle|>impl Default for SnapCircle {
fn default() -> Self ... | code_fim | easy | {
"lang": "rust",
"repo": "Liby99/geometry-sketchpad",
"path": "/core/ui/src/resources/snap_circle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jamsa/leetcode path: /rust/src/6.rs
struct Solution {}
impl Solution {
pub fn convert(s: String, num_rows: i32) -> String {
if num_rows == 1 {
return s;
}
let mut rows = Vec::new();
for _ in 0..num_rows {
rows.push(String::new());
... | code_fim | hard | {
"lang": "rust",
"repo": "Jamsa/leetcode",
"path": "/rust/src/6.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
println!("{:?}", Solution::convert(String::from("hello"), 3));
println!("{:?}", Solution::convert(String::from("h2"), 3));
println!("{:?}", Solution::convert(String::from("PAYPALISHIRING"), 3));
println!("{:?}", Solution::convert(String::from("AB"), 1));
}<|fim_prefix|>// repo:... | code_fim | hard | {
"lang": "rust",
"repo": "Jamsa/leetcode",
"path": "/rust/src/6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mineichen/aoc2020 path: /day25/src/lib.rs
pub fn count_required_loops(base: usize, key: usize) -> usize {
let mut nr = SubjectNumber::new(base);
let mut ctr = 0;
while nr.value != key {
nr.transform();
ctr += 1;
}
ctr
}
<|fim_suffix|>#[cfg(test)]
mod tests {
... | code_fim | hard | {
"lang": "rust",
"repo": "mineichen/aoc2020",
"path": "/day25/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.value = (self.value * self.base_nr) % 20201227;
}
pub fn transform_many(&mut self, cnt: usize) {
for _ in 0..cnt {
self.transform();
}
}
}
#[cfg(test)]
mod tests {
use {super::*};
#[test]
fn test_example() {
assert_eq!(8, count_requi... | code_fim | hard | {
"lang": "rust",
"repo": "mineichen/aoc2020",
"path": "/day25/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dprint/dprint path: /crates/dprint/src/plugins/implementations/process/communicator.rs
use crate::environment::Environment;
use crate::plugins::FormatConfig;
use crate::plugins::InitializedPluginFormatRequest;
use crate::utils::AsyncMutex;
use anyhow::Result;
use dprint_core::configuration::Conf... | code_fim | hard | {
"lang": "rust",
"repo": "dprint/dprint",
"path": "/crates/dprint/src/plugins/implementations/process/communicator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // ensure basic formatting works
{
let formatted_text = communicator
.format_text(InitializedPluginFormatRequest {
file_path: PathBuf::from("test.txt"),
file_text: "testing".to_string(),
range: None,
config: form... | code_fim | hard | {
"lang": "rust",
"repo": "dprint/dprint",
"path": "/crates/dprint/src/plugins/implementations/process/communicator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eetion/iter_type path: /src/main.rs
use itertools::Itertools;
use itertools::kmerge_by;
fn main() {
<|fim_suffix|> let a = vec![-1f64, 2., 3., -5., 6., -7.];
let b = vec![0., 2., -4.];
//let mut it = Itertools::kmerge_by( vec![a, b].into_iter(), |a: f64, b: f64| a.abs() < b.abs() );... | code_fim | easy | {
"lang": "rust",
"repo": "Eetion/iter_type",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = vec![-1f64, 2., 3., -5., 6., -7.];
let b = vec![0., 2., -4.];
//let mut it = Itertools::kmerge_by( vec![a, b].into_iter(), |a: f64, b: f64| a.abs() < b.abs() );
let mut it = vec![a, b].into_iter().kmerge_by(|a, b| a.abs() < b.abs());
let mut it = kmerge_by(vec![a, b].into_iter(... | code_fim | easy | {
"lang": "rust",
"repo": "Eetion/iter_type",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Hello, world!");
let a = vec![-1f64, 2., 3., -5., 6., -7.];
let b = vec![0., 2., -4.];
//let mut it = Itertools::kmerge_by( vec![a, b].into_iter(), |a: f64, b: f64| a.abs() < b.abs() );
let mut it = vec![a, b].into_iter().kmerge_by(|a, b| a.abs() < b.abs());
let mut ... | code_fim | easy | {
"lang": "rust",
"repo": "Eetion/iter_type",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Retrieve information about a published package.
#[derive(Args, Debug)]
pub struct Options {
#[clap(long, env = "ENARX_CA_BUNDLE")]
ca_bundle: Option<Utf8PathBuf>,
#[clap(long, default_value = "https://auth.profian.com/")]
oidc_domain: Url,
#[clap(long, env = "ENARX_INSECURE_AUTH_TO... | code_fim | medium | {
"lang": "rust",
"repo": "enarx/enarx",
"path": "/src/cli/package/info.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: enarx/enarx path: /src/cli/package/info.rs
// SPDX-License-Identifier: Apache-2.0
use crate::drawbridge::{client, TagSpec};
use std::ffi::OsString;
use std::process::ExitCode;
<|fim_suffix|>/// Retrieve information about a published package.
#[derive(Args, Debug)]
pub struct Options {
#[c... | code_fim | medium | {
"lang": "rust",
"repo": "enarx/enarx",
"path": "/src/cli/package/info.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Options {
pub fn execute(self) -> anyhow::Result<ExitCode> {
let cl = client(
self.spec.host,
self.oidc_domain,
self.insecure_auth_token,
self.ca_bundle,
self.credential_helper,
)?;
let tag = cl.tag(&self.spec.ctx... | code_fim | hard | {
"lang": "rust",
"repo": "enarx/enarx",
"path": "/src/cli/package/info.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pantsbuild/pants path: /src/rust/engine/grpc_util/src/hyper_util.rs
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::ops::Deref;
use std::pin::Pin;
use std::task::{Context, Poll};
use futures::Stream;
u... | code_fim | medium | {
"lang": "rust",
"repo": "pantsbuild/pants",
"path": "/src/rust/engine/grpc_util/src/hyper_util.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Pin::new(&mut self.0).poll_accept(cx)
}
}<|fim_prefix|>// repo: pantsbuild/pants path: /src/rust/engine/grpc_util/src/hyper_util.rs
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Lic... | code_fim | hard | {
"lang": "rust",
"repo": "pantsbuild/pants",
"path": "/src/rust/engine/grpc_util/src/hyper_util.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Sets the purpose for a channel.
///
/// Wraps https://api.slack.com/methods/channels.setPurpose
#[derive(Clone, Debug, Serialize, new)]
pub struct SetPurposeRequest<'a> {
/// Channel to set the purpose of
pub channel: ::ChannelId,
/// The new purpose
pub purpose: &'a str,
}
#[derive(... | code_fim | hard | {
"lang": "rust",
"repo": "saethlin/omnichat",
"path": "/slack/src/http/channels.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saethlin/omnichat path: /slack/src/http/channels.rs
//! Get info on your team's Slack channels, create or archive channels, invite users, set the topic and purpose, and mark a channel as read.
use rtm::{Channel, Cursor, Message, Paging};
use timestamp::Timestamp;
/// Archives a channel.
///
//... | code_fim | hard | {
"lang": "rust",
"repo": "saethlin/omnichat",
"path": "/slack/src/http/channels.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rect2 = Rectangle {
width: 30,
length: 40,
};
let (area, mut rect2) = rect2.area2();
println!("a área do retângulo é:{:#?}", rect2);
}<|fim_prefix|>// repo: fernandomarca/rust_exemplos path: /src/strutcs2.rs
fn main() {
#[derive(Debug)]
struct Rectangle {... | code_fim | hard | {
"lang": "rust",
"repo": "fernandomarca/rust_exemplos",
"path": "/src/strutcs2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fernandomarca/rust_exemplos path: /src/strutcs2.rs
fn main() {
#[derive(Debug)]
struct Rectangle {
width: u32,
length: u32,
}
impl Rectangle {
fn area(&self) -> u32 {
<|fim_suffix|> (self.length * self.width, self)
}
}
let rect... | code_fim | medium | {
"lang": "rust",
"repo": "fernandomarca/rust_exemplos",
"path": "/src/strutcs2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elliots/protoc-gen-twirp_swagger path: /example/servers/rust-server/examples/client.rs
#![allow(missing_docs, unused_variables, trivial_casts)]
extern crate swagger_client;
#[allow(unused_extern_crates)]
extern crate futures;
#[allow(unused_extern_crates)]
extern crate swagger;
#[allow(unused_e... | code_fim | hard | {
"lang": "rust",
"repo": "elliots/protoc-gen-twirp_swagger",
"path": "/example/servers/rust-server/examples/client.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Disabled because there's no example.
// Some("MakeHat") => {
// let result = client.make_hat(???).wait();
// println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
// },
_ => {
... | code_fim | hard | {
"lang": "rust",
"repo": "elliots/protoc-gen-twirp_swagger",
"path": "/example/servers/rust-server/examples/client.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Some((x * y * z));
}
}
}
None
}<|fim_prefix|>// repo: ayrat-playground/exercism_rust path: /pythagorean-triplet/src/lib.rs
pub fn find() -> Option<u32> {
for x in 1.. {
'inner:
for y in 1.. {
let z = 1000 - x - ... | code_fim | hard | {
"lang": "rust",
"repo": "ayrat-playground/exercism_rust",
"path": "/pythagorean-triplet/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ayrat-playground/exercism_rust path: /pythagorean-triplet/src/lib.rs
pub fn find() -> Option<u32> {
for x in 1.. {
'inner:
for y in 1.. {
let z = 1000 - x - y;
if z < 1 {
break 'inner;
}
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "ayrat-playground/exercism_rust",
"path": "/pythagorean-triplet/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>eb.ts",
},
NodeModulePolyfill {
name: "string_decoder",
specifier: "ext:deno_node/string_decoder.ts",
},
NodeModulePolyfill {
name: "sys",
specifier: "ext:deno_node/sys.ts",
},
NodeModulePolyfill {
name: "timers",
specifier: "ext:deno_node/timers.ts",
},
NodeModuleP... | code_fim | hard | {
"lang": "rust",
"repo": "liyang31tg/deno",
"path": "/ext/node/polyfill.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liyang31tg/deno path: /ext/node/polyfill.rs
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
pub fn find_builtin_node_module(
module_name: &str,
) -> Option<&NodeModulePolyfill> {
SUPPORTED_BUILTIN_NODE_MODULES
.iter()
.find(|m| m.name == module_name)
}
pu... | code_fim | hard | {
"lang": "rust",
"repo": "liyang31tg/deno",
"path": "/ext/node/polyfill.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: graphprotocol/graph-node path: /core/src/subgraph/context/instance.rs
use futures01::sync::mpsc::Sender;
use graph::{
blockchain::Blockchain,
data_source::{
causality_region::CausalityRegionSeq, offchain, CausalityRegion, DataSource,
DataSourceTemplate, TriggerData,
}... | code_fim | hard | {
"lang": "rust",
"repo": "graphprotocol/graph-node",
"path": "/core/src/subgraph/context/instance.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(if self.hosts.hosts().contains(&host) {
None
} else {
self.hosts.push(host.clone());
Some(host)
})
}
/// Reverts any DataSources that have been added from the block forwards (inclusively)
/// This function also reverts the done_at... | code_fim | hard | {
"lang": "rust",
"repo": "graphprotocol/graph-node",
"path": "/core/src/subgraph/context/instance.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sql.push_str(&res_target_returning(&self.returningList));
sql
}
}
impl Diff for UpdateStmt {}<|fim_prefix|>// repo: isgasho/pg-schema-diff path: /src/nodes/update_stmt.rs
use crate::nodes::res_target::{res_target_returning, res_target_update};
use crate::schema_set::{Diff, Sql, SqlL... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/pg-schema-diff",
"path": "/src/nodes/update_stmt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/pg-schema-diff path: /src/nodes/update_stmt.rs
use crate::nodes::res_target::{res_target_returning, res_target_update};
use crate::schema_set::{Diff, Sql, SqlList};
use postgres_parser::nodes::UpdateStmt;
<|fim_suffix|> let mut sql = String::new();
sql.push_str(&self.wit... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/pg-schema-diff",
"path": "/src/nodes/update_stmt.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sql.push_str(&self.withClause.sql());
sql.push_str("UPDATE ");
sql.push_str(&self.relation.sql());
sql.push_str(" SET ");
sql.push_str(&res_target_update(&self.targetList));
if self.fromClause.is_some() {
sql.push_str(" FROM ");
sql... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/pg-schema-diff",
"path": "/src/nodes/update_stmt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ClassFile {
pub fn new(buf: &[u8]) -> ClassFile {
builder::ClassFileBuilder {
buf,
constant_pool: constant_pool::ConstantPool::new(
0,
Vec::<constant_pool::CPIndexType>::new(),
),
}
.parse()
}
}<|fim_p... | code_fim | hard | {
"lang": "rust",
"repo": "GreatGodOfFire/JavaDecompiler",
"path": "/src/disassembler/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GreatGodOfFire/JavaDecompiler path: /src/disassembler/mod.rs
pub mod attribute;
pub mod builder;
pub mod constant_pool;
pub mod field;
pub mod interface;
pub mod method;
<|fim_suffix|>impl ClassFile {
pub fn new(buf: &[u8]) -> ClassFile {
builder::ClassFileBuilder {
buf,... | code_fim | hard | {
"lang": "rust",
"repo": "GreatGodOfFire/JavaDecompiler",
"path": "/src/disassembler/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
self.total_routers
}
fn num_servers(&self) -> usize
{
self.routers_per_level[0]*self.servers_per_leaf
}
///First upwards, then downwards. Thus being coherent with the servers last convention.
///The link-class is k for the k-th stage, and stages.len() for the server links.
fn neighbour(&self... | code_fim | hard | {
"lang": "rust",
"repo": "codefan-byte/caminos-tfg",
"path": "/src/topology/multistage.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: codefan-byte/caminos-tfg path: /src/topology/multistage.rs
outers_per_level[level]);
if port<deg_up
{
//Go upwards
let (neighbour_offset,neighbour_down_index)=self.stages[level].to_above(offset,port,self.group_sizes[level],self.routers_per_level[level]);
let neighbour = self.pa... | code_fim | hard | {
"lang": "rust",
"repo": "codefan-byte/caminos-tfg",
"path": "/src/topology/multistage.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let base_bottom_size = bottom_size/self.multiplier;
let base_deg = self.base.amount_to_below(above_router,group_size,base_bottom_size);
base_deg * self.multiplier
}
fn to_above(&self, below_router:usize, index:usize, group_size:usize, bottom_size: usize) -> (usize,usize)
{
let base_bottom_si... | code_fim | hard | {
"lang": "rust",
"repo": "codefan-byte/caminos-tfg",
"path": "/src/topology/multistage.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>:{Error as FormatError, StatusFormats};<|fim_prefix|>// repo: syusui-s/mcnotify-rust path: /src/status_checker/mod.rs
mod checker;
mod formats;
pub use self::checker::{Status, StatusChecker, Sta<|fim_middle|>tusDifference};
pub use self::formats: | code_fim | easy | {
"lang": "rust",
"repo": "syusui-s/mcnotify-rust",
"path": "/src/status_checker/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: syusui-s/mcnotify-rust path: /src/status_checker/mod.rs
mod checker;
mod formats;
pub use self::checker::{Status, StatusChecker, Sta<|fim_suffix|>:{Error as FormatError, StatusFormats};<|fim_middle|>tusDifference};
pub use self::formats: | code_fim | easy | {
"lang": "rust",
"repo": "syusui-s/mcnotify-rust",
"path": "/src/status_checker/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: devyntk/cs425-final-project path: /src/employee_list.rs
use crate::{Message, Page, User};
use iced::button;
use iced::{Button, Column, Element, Row, Text};
use postgres::Client;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub enum EmployeeListMessage {
Back,
Edit(i32),
L... | code_fim | hard | {
"lang": "rust",
"repo": "devyntk/cs425-final-project",
"path": "/src/employee_list.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn update(
&mut self,
msg: EmployeeListMessage,
client: &mut Client,
_user: &User,
) -> Option<Message> {
match msg {
EmployeeListMessage::Load => {
let emp_list = client.query("SELECT * FROM employee", &[]);
... | code_fim | hard | {
"lang": "rust",
"repo": "devyntk/cs425-final-project",
"path": "/src/employee_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>[
n
.
.
]
)
;
n
}
fn
copy_to_bytes
(
&
mut
self
len
:
usize
)
-
>
Bytes
{
let
a_rem
=
self
.
a
.
remaining
(
)
;
if
a_rem
>
=
len
{
self
.
a
.
copy_to_bytes
(
len
)
}
else
if
a_rem
=
=
0
{
self
.
b
.
copy_to_bytes
(
len
)
}
else
{
assert
!
(
len
-
a_rem
<
=
self
.
b
.
remaining
(
)
"
len
greater
than
rema... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/bytes/src/buf/chain.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/bytes/src/buf/chain.rs
use
crate
:
:
buf
:
:
{
IntoIter
UninitSlice
}
;
use
crate
:
:
{
Buf
BufMut
Bytes
}
;
#
[
cfg
(
feature
=
"
std
"
)
]
use
std
:
:
io
:
:
IoSlice
;
/
/
/
A
Chain
sequences
two
buffers
.
/
/
/
/
/
/
Chain
is
an
adapter
that... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/bytes/src/buf/chain.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: casimir/ced path: /core/src/editor/menu.rs
use std::cmp::Ordering;
use std::fmt;
use std::ops::Deref;
use crate::editor::{Editor, EditorInfo};
use regex::{CaptureLocations, Regex};
use remote::jsonrpc;
use remote::protocol::{
notifications::{MenuParams, MenuParamsEntry},
Face, TextFragm... | code_fim | hard | {
"lang": "rust",
"repo": "casimir/ced",
"path": "/core/src/editor/menu.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn deref(&self) -> &Self::Target {
&self.0
}
}
pub struct MenuFilter {
pub search: String,
}
impl MenuFilter {
pub fn new(search: &str) -> MenuFilter {
MenuFilter {
search: search.to_string(),
}
}
fn build_regex(&self) -> Regex {
let e... | code_fim | hard | {
"lang": "rust",
"repo": "casimir/ced",
"path": "/core/src/editor/menu.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nicholastmosher/stm32f103xx path: /src/can.rs
mut self) -> _FB22W {
_FB22W { w: self }
}
# [ doc = "Bit 23 - Filter bits" ]
# [ inline ( always ) ]
pub fn fb23(&mut self) -> _FB23W {
_FB23W { w: self }
}
# [ doc = "Bit 24 - ... | code_fim | hard | {
"lang": "rust",
"repo": "nicholastmosher/stm32f103xx",
"path": "/src/can.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> # [ inline ( always ) ]
pub fn is_clear(&self) -> bool {
!self.bit()
}
# [ doc = r" Returns `true` if the bit is set (1)" ]
# [ inline ( always ) ]
pub fn is_set(&self) -> bool {
self.bit()
}
}
# [ doc = r" Value of th... | code_fim | hard | {
"lang": "rust",
"repo": "nicholastmosher/stm32f103xx",
"path": "/src/can.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>ear(&self) -> bool {
!self.bit()
}
# [ doc = r" Returns `true` if the bit is set (1)" ]
# [ inline ( always ) ]
pub fn is_set(&self) -> bool {
self.bit()
}
}
# [ doc = r" Value of the field" ]
pub struct CODER {
bits: u8,
... | code_fim | hard | {
"lang": "rust",
"repo": "nicholastmosher/stm32f103xx",
"path": "/src/can.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakyle/rust-algos path: /src/find_center.rs
pub fn find_center(edges: Vec<Vec<i32>>) -> i32 {
use std::collections::HashMap;
let mut count: HashMap<i32, i32> = HashMap::new();
<|fim_suffix|> if let Some(kvp) = count.iter().max_by(|a, b| a.1.cmp(b.1)) {
*kvp.0
} else {
... | code_fim | medium | {
"lang": "rust",
"repo": "jakyle/rust-algos",
"path": "/src/find_center.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(kvp) = count.iter().max_by(|a, b| a.1.cmp(b.1)) {
*kvp.0
} else {
0
}
}<|fim_prefix|>// repo: jakyle/rust-algos path: /src/find_center.rs
pub fn find_center(edges: Vec<Vec<i32>>) -> i32 {
use std::collections::HashMap;
<|fim_middle|> let mut count: HashMap<... | code_fim | medium | {
"lang": "rust",
"repo": "jakyle/rust-algos",
"path": "/src/find_center.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blackspotbear/rtnw-rs path: /src/rt/transform/translate.rs
extern crate cgmath;
use cgmath::Vector3;
use super::super::renderer::Ray;
use super::super::renderer::Hitable;
use super::super::renderer::HitRecord;
use super::super::renderer::AABB;
pub struct Translate {
pub ptr: Box<dyn Hitab... | code_fim | hard | {
"lang": "rust",
"repo": "blackspotbear/rtnw-rs",
"path": "/src/rt/transform/translate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Hitable for Translate {
fn hit(&self, r: &Ray, t0: f32, t1: f32) -> Option<HitRecord> {
let moved_r = Ray::new(r.origin() - self.offset, r.direction(), r.time());
if let Some(mut rec) = self.ptr.hit(&moved_r, t0, t1) {
rec.p += self.offset;
Some(rec)
... | code_fim | hard | {
"lang": "rust",
"repo": "blackspotbear/rtnw-rs",
"path": "/src/rt/transform/translate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if *m >= 3 {
*m -= 1;
} else {
*m += 1;
}
cnt += 1;
}
println!("{}", cnt);
}<|fim_prefix|>// repo: Vlad-Shcherbina/aoc2017 path: /src/bin/day05.rs
use std::io::BufRead;
fn main() {
let stdin = std::io::stdin();
let mut mem = Vec::new();
... | code_fim | medium | {
"lang": "rust",
"repo": "Vlad-Shcherbina/aoc2017",
"path": "/src/bin/day05.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vlad-Shcherbina/aoc2017 path: /src/bin/day05.rs
use std::io::BufRead;
fn main() {
let stdin = std::io::stdin();
let mut mem = Vec::new();
for line in stdin.lock().lines() {
let line = line.unwrap();
let x: i32 = line.parse().unwrap();
mem.push(x);
}
l... | code_fim | medium | {
"lang": "rust",
"repo": "Vlad-Shcherbina/aoc2017",
"path": "/src/bin/day05.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ref mut req_info) = req_info {
if !shared_data_maps.is_empty() {
req_info.shared_data_maps.replace(shared_data_maps.clone());
}
}
let ext = req.extensions_mut();
ext.insert(shared_data_maps);
let res_pre = self
... | code_fim | hard | {
"lang": "rust",
"repo": "seanpianka/routerify",
"path": "/src/router/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> resp = Some(route_resp);
break;
}
}
}
Err(err_response) => {
resp = Some(err_response);
}
};
if resp.is_none() {
let e = "No handlers added t... | code_fim | hard | {
"lang": "rust",
"repo": "seanpianka/routerify",
"path": "/src/router/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seanpianka/routerify path: /src/router/mod.rs
thod, Request, Response, StatusCode};
use regex::RegexSet;
use std::any::Any;
use std::fmt::{self, Debug, Formatter};
use std::future::Future;
use std::pin::Pin;
pub use self::builder::RouterBuilder;
mod builder;
pub(crate) type ErrHandlerWithoutI... | code_fim | hard | {
"lang": "rust",
"repo": "seanpianka/routerify",
"path": "/src/router/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Undin/shows-notifier path: /server/src/main.rs
about TV show. For example, `/subscribe lostfilm Daredevil`", PermissionLevel::User),
command!("unsubscribe", &["source", "show title"], "Remove subscription. For example, `/unsubscribe lostfilm Daredevil`", PermissionLevel::User),
command!... | code_fim | hard | {
"lang": "rust",
"repo": "Undin/shows-notifier",
"path": "/server/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Undin/shows-notifier path: /server/src/main.rs
issionLevel::User),
command!("unsubscribe", &["source", "show title"], "Remove subscription. For example, `/unsubscribe lostfilm Daredevil`", PermissionLevel::User),
command!("subscriptions", &[], "List your current subscriptions", Permissio... | code_fim | hard | {
"lang": "rust",
"repo": "Undin/shows-notifier",
"path": "/server/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!("subscriptions command");
let query = sub_table.inner_join(show_table)
.select((source_name, title))
.filter(sub_uid.eq(user_id))
.order((source_name, title));
let ref connection = *components.get_connection();
match query.load::<(String, String)>(connectio... | code_fim | hard | {
"lang": "rust",
"repo": "Undin/shows-notifier",
"path": "/server/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", total);
Ok(())
}
fn two() -> std::io::Result<()> {
let file = File::open(format!("src/day1/input.txt"))?;
let mut total: f32 = 0.0;
for line in BufReader::new(file).lines() {
let mut cost: f32 = line?.parse::<f32>().unwrap();
while cost > 0.0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "mattiaslundberg/legendary-fortnight",
"path": "/aoc2019/src/day1/solve.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mattiaslundberg/legendary-fortnight path: /aoc2019/src/day1/solve.rs
use std::fs::File;
use std::io::{BufRead, BufReader, Result};
fn one() -> std::io::Result<()> {
<|fim_suffix|> println!("{}", total);
Ok(())
}
fn two() -> std::io::Result<()> {
let file = File::open(format!("src/da... | code_fim | hard | {
"lang": "rust",
"repo": "mattiaslundberg/legendary-fortnight",
"path": "/aoc2019/src/day1/solve.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uesugi6111/io_pro path: /src/lib.rs
pub mod io_pro {
#[macro_export]
macro_rules!
input{
(sc=$sc:expr,$($r:tt)*)=>{
input_inner!{$sc,$($r)*}
};
($($r:tt)*)=>{
let mut sc=io_pro::Scanner::new(std::io::stdin().lock());
inp... | code_fim | hard | {
"lang": "rust",
"repo": "uesugi6111/io_pro",
"path": "/src/lib.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[macro_export]
macro_rules! read_value{
($sc:expr,($($t:tt),*))=>{
($(read_value!($sc,$t)),*)
};
($sc:expr,[$t:tt;$len:expr])=>{
(0..$len).map(|_|read_value!($sc,$t)).collect::<Vec<_>>()
};
($sc:expr,Chars)=>{read_value!($sc,String).... | code_fim | hard | {
"lang": "rust",
"repo": "uesugi6111/io_pro",
"path": "/src/lib.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Self::new(ptr, lookup_struct, utxos, wallet_name.as_ref().to_path_buf()))
}
/// update a given state with a set of blocks.
///
/// The blocks need to be in blockchain order,
/// and correctly refer to each other, otherwise
/// an error is emitted
pub fn forward(&mut... | code_fim | hard | {
"lang": "rust",
"repo": "ilyadruzh/zen",
"path": "/examples/rust/rust-cardano/wallet-cli/src/command/wallet/state/lookup.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ilyadruzh/zen path: /examples/rust/rust-cardano/wallet-cli/src/command/wallet/state/lookup.rs
use std::{result, fmt, path::{Path, PathBuf}};
use std::collections::BTreeMap;
use cardano::block::{Block, BlockDate, HeaderHash};
use cardano::hdwallet;
use cardano::hdpayload;
use cardano::bip::bip44;... | code_fim | hard | {
"lang": "rust",
"repo": "ilyadruzh/zen",
"path": "/examples/rust/rust-cardano/wallet-cli/src/command/wallet/state/lookup.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type Utxos = BTreeMap<TxIn, Utxo>;
pub trait AddrLookup {
/// given the lookup structure, return the list
/// of matching addresses. note that for some
/// algorithms, self mutates to optimise the next lookup query
fn lookup(&mut self, ptr: &StatePtr, outs: &[(TxId, u32, &TxOut)]) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "ilyadruzh/zen",
"path": "/examples/rust/rust-cardano/wallet-cli/src/command/wallet/state/lookup.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /sdk/storage_datalake/tests/files.rs
use azure_storage_datalake::Properties;
use std::{assert_eq, assert_ne};
mod setup;
#[tokio::test]
async fn file_create_delete() -> azure_core::Result<()> {
let data_lake_client = setup::create_data_lake_client("datalake_f... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/sdk/storage_datalake/tests/files.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_suffix|> file_system_client.delete().await?;
Ok(())
}
#[tokio::test]
async fn file_upload() -> azure_core::Result<()> {
let data_lake_client = setup::create_data_lake_client("datalake_file_upload")
.await
.unwrap();
let file_system_name = "azurerustsdk-datalake-file-upload";
... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/sdk/storage_datalake/tests/files.rs",
"mode": "spm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wenxiang-Li/abstreet path: /widgetry/src/widgets/image.rs
use crate::{
Color, DrawWithTooltips, EventCtx, GeomBatch, JustDraw, RewriteColor, ScreenDims, ScreenPt,
Text, Widget,
};
pub struct Image<'a> {
filename: &'a str,
tooltip: Option<Text>,
color: Option<RewriteColor>,
}... | code_fim | hard | {
"lang": "rust",
"repo": "wenxiang-Li/abstreet",
"path": "/widgetry/src/widgets/image.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Transform the color of the image.
pub fn color<RWC: Into<RewriteColor>>(mut self, color: RWC) -> Self {
self.color = Some(color.into());
self
}
pub fn into_widget(self, ctx: &EventCtx) -> Widget {
// TODO: consolidate the impl from widgetry::widgets::button::Im... | code_fim | hard | {
"lang": "rust",
"repo": "wenxiang-Li/abstreet",
"path": "/widgetry/src/widgets/image.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (mut batch, bounds) = crate::svg::load_svg(ctx.prerender, self.filename);
let color = self
.color
.unwrap_or(RewriteColor::ChangeAll(ctx.style.icon_fg));
batch = batch.color(color);
// Preserve the padding in the SVG.
// TODO Maybe alwa... | code_fim | hard | {
"lang": "rust",
"repo": "wenxiang-Li/abstreet",
"path": "/widgetry/src/widgets/image.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yamash723/pixelast path: /src/http_client.rs
use reqwest;
use reqwest::Client;
use reqwest::header::{HeaderMap, HeaderValue};
use std::collections::HashMap;
pub enum MethodType {
Get,
Post,
Put,
Delete,
}
#[derive(Hash, PartialEq, Eq)]
pub enum HeaderType {
UserToken,
C... | code_fim | hard | {
"lang": "rust",
"repo": "yamash723/pixelast",
"path": "/src/http_client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
uri,
method,
body,
headers,
}
}
pub fn insert_header(&mut self, header_type: HeaderType, value : &'a str) {
self.headers.insert(header_type, value);
}
}
pub trait HttpClient {
fn do_request(context: &RequestCo... | code_fim | hard | {
"lang": "rust",
"repo": "yamash723/pixelast",
"path": "/src/http_client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait HttpClient {
fn do_request(context: &RequestContext) -> Result<String, reqwest::Error>;
}
pub struct TinyHttpClient;
impl HttpClient for TinyHttpClient {
fn do_request(context: &RequestContext) -> Result<String, reqwest::Error> {
let client = Client::new();
let mut req ... | code_fim | hard | {
"lang": "rust",
"repo": "yamash723/pixelast",
"path": "/src/http_client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: j-mcavoy/antboat path: /src/antennapod/schema.rs
#![allow(non_snake_case)]
#[derive(Debug)]
pub struct Metadata {
pub db_schema_version_major: u8,
pub db_schema_version_minor: u8,
}
#[derive(Debug)]
pub struct AndroidMetaData {}
#[derive(Debug)]
pub struct Favorites {
pub id: u64,... | code_fim | hard | {
"lang": "rust",
"repo": "j-mcavoy/antboat",
"path": "/src/antennapod/schema.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct FeedMedia {
pub id: u64,
pub duration: u64,
pub file_url: String,
pub download_url: String,
pub downloaded: bool,
pub position: u64,
pub filesize: u64,
pub mime_type: String,
pub playback_completion_date: u64,
pub feeditem: u64,
pub p... | code_fim | hard | {
"lang": "rust",
"repo": "j-mcavoy/antboat",
"path": "/src/antennapod/schema.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> info!("Peer: {:?}", peer);
if peer.version < constants.min_peer_proto_version {
error!("Peer {:?} using obsolete version {}; disconnecting", remote_addr, peer.version);
peer.disconnect = true;
peerdb.write(&key, peer).unwrap();
return response;
... | code_fim | hard | {
"lang": "rust",
"repo": "Beirdo/rustcoinbase",
"path": "/src/bin/rustcoinbase/p2pserver.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Beirdo/rustcoinbase path: /src/bin/rustcoinbase/p2pserver.rs
use log::*;
use futures::{future, prelude::*};
use rustcoinbase::rustcoinlib::p2pservice::*;
use rustcoinbase::rustcoinlib::peerdb::*;
use rustcoinbase::rustcoinlib::settings::*;
use rustcoinbase::rustcoinlib::constants::*;
use rustcoi... | code_fim | hard | {
"lang": "rust",
"repo": "Beirdo/rustcoinbase",
"path": "/src/bin/rustcoinbase/p2pserver.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_grupo(&mut self, nome_grupo: &String) -> Option<&Grupo> {
for grupo in &self.grupos {
if grupo.get_nome() == nome_grupo {
return Some(grupo);
}
}
None
}
pub fn verificar_pertinencia_a_grupo(&mut self, nome_grupo: &Stri... | code_fim | hard | {
"lang": "rust",
"repo": "YoYolops/controle-alunos",
"path": "/rust/src/repositories/grupos.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YoYolops/controle-alunos path: /rust/src/repositories/grupos.rs
use crate::models::{
grupo::Grupo,
aluno::Aluno
};
pub struct RepositorioGrupos {
grupos: Vec<Grupo>
}
impl RepositorioGrupos {
pub fn new() -> Self {
RepositorioGrupos { grupos: Vec::new() }
}
<|fim_s... | code_fim | hard | {
"lang": "rust",
"repo": "YoYolops/controle-alunos",
"path": "/rust/src/repositories/grupos.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn display_grupos_do_estudante(&self, matricula: &String) {
for grupo in &self.grupos {
if grupo.is_aluno_alocado(matricula) {
println!("- {}", grupo.get_nome())
}
}
}
}<|fim_prefix|>// repo: YoYolops/controle-alunos path: /rust/src/repo... | code_fim | hard | {
"lang": "rust",
"repo": "YoYolops/controle-alunos",
"path": "/rust/src/repositories/grupos.rs",
"mode": "spm",
"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.