text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>impl MsgEnum {
pub fn to_payload(&self, pk: &str, dn: &str, ack: i32) -> Result<(String, Vec<u8>)> {
use MsgEnum::*;
match &self {
PropertyPost(data) => {
let topic = format!("/sys/{}/{}/thing/event/property/post", pk, dn);
let method = "thin... | code_fim | hard | {
"lang": "rust",
"repo": "dakongyi2014/aiot-rust",
"path": "/src/dm/msg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for message in consumer.receiver().iter() {
match message {
ConsumerMessage::Delivery(delivery) => {
if delivery.properties.correlation_id().as_ref() == Some(&correlation_id) {
let resp = String::from_utf8_lossy(&delivery.body);
... | code_fim | hard | {
"lang": "rust",
"repo": "gabriel128/news_feed",
"path": "/examples/bindings_p.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gabriel128/news_feed path: /examples/bindings_p.rs
use amiquip::{AmqpProperties, Connection, ConsumerMessage, ConsumerOptions, ExchangeDeclareOptions, ExchangeType, Publish, QueueDeclareOptions, Result};
fn main() -> Result<()> {
let mut connection = Connection::insecure_open("amqp://guest:... | code_fim | hard | {
"lang": "rust",
"repo": "gabriel128/news_feed",
"path": "/examples/bindings_p.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait DbManage {
fn new_pool(max_size: Option<u32>) -> Self;
fn connection(&self) -> Result<DbConnection, ApiError>;
}
impl DbManage for DbPool {
fn new_pool(max_size: Option<u32>) -> Self {
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
le... | code_fim | medium | {
"lang": "rust",
"repo": "nlopes/avro-schema-registry",
"path": "/src/db/connection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn connection(&self) -> Result<DbConnection, ApiError>;
}
impl DbManage for DbPool {
fn new_pool(max_size: Option<u32>) -> Self {
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let manager = ConnectionManager::<PgConnection>::new(database_url);
... | code_fim | hard | {
"lang": "rust",
"repo": "nlopes/avro-schema-registry",
"path": "/src/db/connection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nlopes/avro-schema-registry path: /src/db/connection.rs
use std::env;
use diesel::pg::PgConnection;
use diesel::r2d2::{ConnectionManager, Pool, PooledConnection};
use crate::api::errors::{ApiAvroErrorCode, ApiError};
<|fim_suffix|> fn connection(&self) -> Result<DbConnection, ApiError>;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "nlopes/avro-schema-registry",
"path": "/src/db/connection.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // does it contain a word?
println!("Contains hello? : {}", hello.contains("ello"));
// check more operations in the documentation
}<|fim_prefix|>// repo: harshmunshioxolo/Rust-Experiments path: /src/strings.rs
// Primitive strings = Immutable fixed length string in the memory
// String = Gr... | code_fim | hard | {
"lang": "rust",
"repo": "harshmunshioxolo/Rust-Experiments",
"path": "/src/strings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: harshmunshioxolo/Rust-Experiments path: /src/strings.rs
// Primitive strings = Immutable fixed length string in the memory
// String = Growable, heal allowcated
pub fn run() {
let mut hello = String::from("Hello");
// Get length of the string
println!("{}", hello.len());
prin... | code_fim | medium | {
"lang": "rust",
"repo": "harshmunshioxolo/Rust-Experiments",
"path": "/src/strings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swordsmanluke/weather_hud path: /src/darksky_client.rs
use restson::{Error, RestClient, RestPath};
use crate::forecast::LatLong;
const URL_BASE: &str = "https://api.darksky.net/";
pub trait DarkSkyClient {
fn forecasts(&mut self) -> Result<DSForecasts, Error>;
<|fim_suffix|>#[derive(Serial... | code_fim | hard | {
"lang": "rust",
"repo": "swordsmanluke/weather_hud",
"path": "/src/darksky_client.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl DarkSkyRestClient {
pub fn new(token: String, location: LatLong) -> DarkSkyRestClient {
DarkSkyRestClient {
token,
location,
}
}
pub fn get_client(&self) -> Result<RestClient, Error> {
let mut client = RestClient::new(URL_BASE)?;
Ok... | code_fim | medium | {
"lang": "rust",
"repo": "swordsmanluke/weather_hud",
"path": "/src/darksky_client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_client(&self) -> Result<RestClient, Error> {
let mut client = RestClient::new(URL_BASE)?;
Ok(client)
}
}
impl DarkSkyClient for DarkSkyRestClient {
fn forecasts(&mut self) -> Result<DSForecasts, Error> {
let mut client = self.get_client()?;
let args ... | code_fim | hard | {
"lang": "rust",
"repo": "swordsmanluke/weather_hud",
"path": "/src/darksky_client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brentward/rustos path: /lib/bw_allocator/src/allocator/bin.rs
use core::alloc::Layout;
use core::fmt;
use crate::allocator::util::*;
use crate::allocator::linked_list::LinkedList;
use crate::LocalAlloc;
use kernel_api::syscall::sbrk;
const USER_VMM_ADDRESS_SIZE: usize= 30;
const BIN_COUNT_MAX: ... | code_fim | hard | {
"lang": "rust",
"repo": "brentward/rustos",
"path": "/lib/bw_allocator/src/allocator/bin.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn map_to_bin(&self, layout: &Layout) -> usize {
let required_size = layout.size().max(layout.align());
for index in 0..self.bins.len() {
if Allocator::bin_size(index) >= required_size{
return index
}
}
panic!("layout will cause m... | code_fim | hard | {
"lang": "rust",
"repo": "brentward/rustos",
"path": "/lib/bw_allocator/src/allocator/bin.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.re == rhs.re && self.im == rhs.im
}
}
// Eq will inherit from PartialEq
// don't need to re impl again
impl<T> Eq for Complex<T>
where T: Eq{}
pub fn main() {
let mut complex_1 = Complex::new(1, 2);
let mut complex_2 = Complex::new(3, 4);
println!("complex_1: {:?}", complex_1);
pri... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenvanquanthinh97/rust-1",
"path": "/traits/src/operator_overloading.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nguyenvanquanthinh97/rust-1 path: /traits/src/operator_overloading.rs
use std::ops::{Add, AddAssign, Neg};
use std::cmp::{Eq, PartialEq};
#[derive(Debug, Copy, Clone)]
struct Complex <T> {
re: T,
im: T
}
impl<T> Complex<T> {
fn new(re: T, im: T) -> Complex<T> {
Complex::<T> {re, im}
... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenvanquanthinh97/rust-1",
"path": "/traits/src/operator_overloading.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/0096-Unique Binary Search Trees/Dynamic Programming.rs
impl Solution {
pub fn num_trees(n: i32) -> i32 {
let n = n as usize;
let mut dp = vec![0; n + 1];
dp[0] = 1;
<|fim_suffix|>+= dp[j - 1] * dp[i - j];
}
}
... | code_fim | medium | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/0096-Unique Binary Search Trees/Dynamic Programming.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 1..=n {
for j in 1..=i {
dp[i] += dp[j - 1] * dp[i - j];
}
}
dp[n]
}
}<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/0096-Unique Binary Search Trees/Dynamic Programming.rs
impl Solution {
pub fn num_trees(n: i32) -> i3... | code_fim | medium | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/0096-Unique Binary Search Trees/Dynamic Programming.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>+= dp[j - 1] * dp[i - j];
}
}
dp[n]
}
}<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/0096-Unique Binary Search Trees/Dynamic Programming.rs
impl Solution {
pub fn num_trees(n: i32) -> i32 {
let n = n as usize;
let mut dp = vec![0; n + 1];
... | code_fim | medium | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/0096-Unique Binary Search Trees/Dynamic Programming.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PriyanshuDas/PermutationsSorting path: /src/permutation/permutation_label.rs
extern crate lehmer;
use lehmer::Lehmer;
use crate::permutation::permutation_helper::reduce_permutation;
use crate::permutation::constants;
//note: HARD limit at 12, may need to increase for larger size
//todo: maybe h... | code_fim | hard | {
"lang": "rust",
"repo": "PriyanshuDas/PermutationsSorting",
"path": "/src/permutation/permutation_label.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut lehmer_code = 0;
let n = permutation.len();
for pos in 0..n {
let mut ct_of_smaller_to_left = 0;
for pos_2 in 0..pos {
if permutation[pos_2] < permutation[pos] {ct_of_smaller_to_left += 1;}
}
lehmer_code += constants::FACTORIALS[n-pos-1]*
... | code_fim | hard | {
"lang": "rust",
"repo": "PriyanshuDas/PermutationsSorting",
"path": "/src/permutation/permutation_label.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dcjohnson/libhackit-v2 path: /src/ast.rs
use token::{Token, Type};
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Ast {
pub node_val: Option<Token>,
child_nodes: Vec<Ast>
}
pub trait AstTrait {
fn push_child(&mut self, ast: Ast);
fn pop_child(&mut self) -> Option<A... | code_fim | hard | {
"lang": "rust",
"repo": "dcjohnson/libhackit-v2",
"path": "/src/ast.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new_null() -> Self {
Ast {
node_val: None,
child_nodes: Vec::new()
}
}
pub fn is_function(&mut self) -> bool {
match self.get_child(0) {
Some(child) => {
let result = match child.node_val {
... | code_fim | hard | {
"lang": "rust",
"repo": "dcjohnson/libhackit-v2",
"path": "/src/ast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xiroV/Cuckoo path: /src/ui/repl/help_controller.rs
use cuckoo::ServiceBundle;
use ui::repl::{ReplUI, Command, CommandHandler};
use std::io::{Read, Write};
<|fim_suffix|> ui.writeln("Valid commands are:");
ui.writeln(" quit - quit this session");
ui.writeln(" config [read|edit] - creat... | code_fim | hard | {
"lang": "rust",
"repo": "xiroV/Cuckoo",
"path": "/src/ui/repl/help_controller.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ui.writeln("Valid commands are:");
ui.writeln(" quit - quit this session");
ui.writeln(" config [read|edit] - create or read configuration files");
command.is_consumed = true;
}<|fim_prefix|>// repo: xiroV/Cuckoo path: /src/ui/repl/help_controller.rs
use cuckoo::ServiceBundle;
use ui::repl... | code_fim | hard | {
"lang": "rust",
"repo": "xiroV/Cuckoo",
"path": "/src/ui/repl/help_controller.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Drop for Framebuffer {
fn drop(&mut self) {
unsafe {
gl::DeleteFramebuffers(1, &mut self.id);
}
}
}<|fim_prefix|>// repo: Rimpampa/mandelbrot-rs path: /src/graphics/framebuffer.rs
use super::texture::Texture;
pub struct Framebuffer {
id: u32,
}
impl Framebuf... | code_fim | hard | {
"lang": "rust",
"repo": "Rimpampa/mandelbrot-rs",
"path": "/src/graphics/framebuffer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rimpampa/mandelbrot-rs path: /src/graphics/framebuffer.rs
use super::texture::Texture;
pub struct Framebuffer {
id: u32,
}
impl Framebuffer {
pub fn new(tex: &Texture) -> Result<Self, String> {
let mut id = 0;
unsafe {
gl::GenFramebuffers(1, &mut id);
... | code_fim | medium | {
"lang": "rust",
"repo": "Rimpampa/mandelbrot-rs",
"path": "/src/graphics/framebuffer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A spanned node
#[derive(Clone, Copy, Debug)]
pub struct Spanned<T> {
/// The node
pub node: T,
/// The span
pub span: Span,
}
impl<A> Spanned<A> {
/// Creates a spanned node
pub fn new(span: Span, node: A) -> Spanned<A> {
Spanned {
node: node,
s... | code_fim | hard | {
"lang": "rust",
"repo": "japaric-archived/lisp.rs",
"path": "/src/syntax/codemap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: japaric-archived/lisp.rs path: /src/syntax/codemap.rs
//! Maps spans to source code
use std::mem;
use std::ops::Index;
/// Byte position
pub type BytePos = usize;
/// Source code
pub struct Source(str);
impl Source {
/// Treats the input string as source code
pub fn new(input: &str) ... | code_fim | hard | {
"lang": "rust",
"repo": "japaric-archived/lisp.rs",
"path": "/src/syntax/codemap.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Maps the spanned node while retaining the span
pub fn map<F>(self, f: F) -> Spanned<F::Output> where F: Fn<(A,)> {
Spanned {
span: self.span,
node: f(self.node)
}
}
}<|fim_prefix|>// repo: japaric-archived/lisp.rs path: /src/syntax/codemap.rs
//! Ma... | code_fim | hard | {
"lang": "rust",
"repo": "japaric-archived/lisp.rs",
"path": "/src/syntax/codemap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ctx.font_size(33.0);
ctx.font("icons");
ctx.fill_paint(Color::rgba_i(255, 255, 255, 128));
ctx.text_align(Align::CENTER|Align::MIDDLE);
ctx.text(Point::new(x+9.0+2.0, y+h*0.5), ICON_CHECK).unwrap();
ctx
}<|fim_prefix|>// repo: othelarian/curly-succotash path: /src/drawing/check_b... | code_fim | hard | {
"lang": "rust",
"repo": "othelarian/curly-succotash",
"path": "/src/drawing/check_box.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: othelarian/curly-succotash path: /src/drawing/check_box.rs
use nvg::{Context, Color, Align, Point, Gradient, Rect, Extent};
use nvg_gl::Renderer;
pub fn draw(
mut ctx: Context<Renderer>,
text: &str,
x: f32, y:f32,
#[allow(unused)]
w: f32, h: f32
) -> Context<Renderer> {
... | code_fim | hard | {
"lang": "rust",
"repo": "othelarian/curly-succotash",
"path": "/src/drawing/check_box.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ent
#![debugger_visualizer(natvis_file = "../foo.random")] //~ ERROR
fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/invalid/invalid-debugger-visualizer-option.rs
// normalize-stderr-test: "foo.random:.*\(" -> "foo.random: $$FILE_NOT_FOUND_MSG ("
// normalize-stderr-test: "os error \d+"... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/invalid/invalid-debugger-visualizer-option.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/invalid/invalid-debugger-visualizer-option.rs
// normalize-stderr-test: "foo.random:.*\(" -> "foo.random: $$FILE_NOT_FOUND_MSG<|fim_suffix|>
#![debugger_visualizer(random_file = "../foo.random")] //~ ERROR invalid argument
#![debugger_visualizer(natvis_file = "../... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/invalid/invalid-debugger-visualizer-option.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/lowpan/lib/openthread_rust/src/ot/types/log_region.rs
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::prelude_internal::*;
///... | code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/lowpan/lib/openthread_rust/src/ot/types/log_region.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<otLogLevel> for LogLevel {
fn from(x: otLogLevel) -> Self {
use num::FromPrimitive;
Self::from_u64(x as u64).unwrap_or_else(|| panic!("Unknown otLogLevel value: {}", x))
}
}
impl From<LogLevel> for otLogLevel {
fn from(x: LogLevel) -> Self {
x as otLogLevel
... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/lowpan/lib/openthread_rust/src/ot/types/log_region.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>name target for the alias.
#[serde(rename = "target")]
pub target: String,
}<|fim_prefix|>// repo: cholcombe973/isilon path: /src/models/snapshot_alias_create_params.rs
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deseria<|fim_middle|>lize)]
pub struct SnapshotAlias... | code_fim | medium | {
"lang": "rust",
"repo": "cholcombe973/isilon",
"path": "/src/models/snapshot_alias_create_params.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cholcombe973/isilon path: /src/models/snapshot_alias_create_params.rs
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deseria<|fim_suffix|>napshot name.
#[serde(rename = "name")]
pub name: String,
/// Snapshot name target for the alias.
#[serde(rename ... | code_fim | medium | {
"lang": "rust",
"repo": "cholcombe973/isilon",
"path": "/src/models/snapshot_alias_create_params.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danylaporte/storm path: /storm_derive/src/lib.rs
#![allow(clippy::indexing_slicing)]
extern crate proc_macro;
#[macro_use]
mod macros;
mod ctx;
mod derive_input_ext;
#[cfg(feature = "mssql")]
mod errors;
mod field_ext;
mod indexing;
mod locks_await;
#[cfg(feature = "mssql")]
mod mssql;
mod no... | code_fim | hard | {
"lang": "rust",
"repo": "danylaporte/storm",
"path": "/storm_derive/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[proc_macro_derive(NoopDelete)]
pub fn noop_delete(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
noop::delete(&input).into()
}
#[proc_macro_derive(NoopLoad)]
pub fn noop_load(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(inpu... | code_fim | hard | {
"lang": "rust",
"repo": "danylaporte/storm",
"path": "/storm_derive/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[proc_macro_derive(NoopLoad)]
pub fn noop_load(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
noop::load(&input).into()
}
#[proc_macro_derive(NoopSave)]
pub fn noop_save(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as D... | code_fim | hard | {
"lang": "rust",
"repo": "danylaporte/storm",
"path": "/storm_derive/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
impl Builder {
/// Create a new Builder in LLVM's global context.
#[allow(dead_code)]
pub fn new() -> Self {
unsafe { Builder { builder: LLVMCreateBuilder() } }
}
#[allow(dead_code)]
pub fn position_at_end(&self, bb: LLVMBasicBlockRef) {
unsafe {
LLVMP... | code_fim | hard | {
"lang": "rust",
"repo": "yotarok/rustre",
"path": "/src/utils/llvm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yotarok/rustre path: /src/utils/llvm.rs
peRef {
unsafe { LLVMPointerType(LLVMInt32Type(), 0) }
}
#[allow(dead_code)]
pub fn int64_ptr_type() -> LLVMTypeRef {
unsafe { LLVMPointerType(LLVMInt64Type(), 0) }
}
#[allow(dead_code)]
pub fn int128_ptr_type() -> LLVMTypeRef {
unsafe { LLVMPo... | code_fim | hard | {
"lang": "rust",
"repo": "yotarok/rustre",
"path": "/src/utils/llvm.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
add_function(module,
"llvm.memset.p0i8.i32",
&mut [int8_ptr_type(), int8_type(), int32_type(), int32_type(), int1_type()],
void);
add_function(module, "malloc", &mut [int32_type()], int8_ptr_type());
add_function(module, "free", &mut ... | code_fim | hard | {
"lang": "rust",
"repo": "yotarok/rustre",
"path": "/src/utils/llvm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/hhvm path: /hphp/hack/src/elab/passes/validate_class_var_user_attribute_lsb.rs
// Copyright (c) Meta Platforms, Inc. and affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use nast::ClassVar;
us... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/elab/passes/validate_class_var_user_attribute_lsb.rs",
"mode": "psm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ua) = elem
.user_attributes
.0
.iter()
.find(|ua| ua.name.name() == sn::user_attributes::LSB)
{
// Non-static properties cannot have attribute `__LSB`
if !elem.is_static {
env.emit_error(Nam... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/elab/passes/validate_class_var_user_attribute_lsb.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_suffix|> let top_byte = ((value & 0xFF00) >> 8) as u8;
let bottom_byte = (value & 0x00FF) as u8;
let parsed = match top_byte
{
0x00 => Unknown(value),
0x01 => match bottom_byte
{
0x00 => Usb(UsbTerminalType::Undefined),
0x01 => Usb(UsbTerminalType::Streaming),
0xFF => Usb(UsbTer... | code_fim | hard | {
"lang": "rust",
"repo": "raphaelcohn/security-keys-rust",
"path": "/workspace/usb-storm/src/interface/audio/control/terminal_types/OutputTerminalType.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/necsim-rust path: /necsim/impls/no-std/src/parallelisation/independent/landscape.rs
use alloc::{collections::VecDeque, vec::Vec};
use core::num::{NonZeroU64, Wrapping};
use necsim_core_bond::NonNegativeF64;
use necsim_core::{
cogs::{
ActiveLineageSampler, DispersalSampler, ... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/necsim-rust",
"path": "/necsim/impls/no-std/src/parallelisation/independent/landscape.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(previous_speciation_sample) = previous_speciation_sample {
if min_spec_samples.insert(previous_speciation_sample) {
if let Some(previous_task) = previous_task {
if previous_task.is_active() {
lineages.push_back(pre... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/necsim-rust",
"path": "/necsim/impls/no-std/src/parallelisation/independent/landscape.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crackcomm/ngraph-rs path: /src/op/mod.rs
mod add;
mod avg_pool;
mod concat;
mod constant;
mod less;
mod less_eq;
mod max_pool;
mod multiply;
mod negative;
mod<|fim_suffix|>:Constant;
pub use self::less::Less;
pub use self::less_eq::LessEqual;
pub use self::max_pool::MaxPool;
pub use self::multip... | code_fim | medium | {
"lang": "rust",
"repo": "crackcomm/ngraph-rs",
"path": "/src/op/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>:multiply::Multiply;
pub use self::negative::Negative;
pub use self::util::{Parameter, ParameterVector, RoundingType};<|fim_prefix|>// repo: crackcomm/ngraph-rs path: /src/op/mod.rs
mod add;
mod avg_pool;
mod concat;
mod constant;
mod less;
mod less_eq;
mod max_pool;
mod multiply;
mod negative;
mod<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "crackcomm/ngraph-rs",
"path": "/src/op/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>:Constant;
pub use self::less::Less;
pub use self::less_eq::LessEqual;
pub use self::max_pool::MaxPool;
pub use self::multiply::Multiply;
pub use self::negative::Negative;
pub use self::util::{Parameter, ParameterVector, RoundingType};<|fim_prefix|>// repo: crackcomm/ngraph-rs path: /src/op/mod.rs
mod ad... | code_fim | medium | {
"lang": "rust",
"repo": "crackcomm/ngraph-rs",
"path": "/src/op/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Add<&Self> for EncoderStats {
type Output = Self;
fn add(self, rhs: &EncoderStats) -> Self::Output {
let mut lhs = self;
lhs += rhs;
lhs
}
}
impl AddAssign<&Self> for EncoderStats {
fn add_assign(&mut self, rhs: &EncoderStats) {
rhs.block_size_counts.iter().for_each(|(&k, &v... | code_fim | hard | {
"lang": "rust",
"repo": "edmond-zhu/rav1e",
"path": "/src/stats.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: edmond-zhu/rav1e path: /src/stats.rs
// Copyright (c) 2019, The rav1e contributors. All rights reserved
//
// This source code is subject to the terms of the BSD 2 Clause License and
// the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
// was not distributed with this s... | code_fim | hard | {
"lang": "rust",
"repo": "edmond-zhu/rav1e",
"path": "/src/stats.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bywayboy/RINAPI path: /code/rinapi/wapi/DeviceContext.rs
use super::super::prelude::{
CCINT , HGDI<|fim_suffix|>n_opt_ */ fnObject : CCINT
) -> HGDIOBJ;
}<|fim_middle|>OBJ
};
#[link(name = "Gdi32")]
extern "stdcall" {
pub fn GetStockObject(
/* _I | code_fim | medium | {
"lang": "rust",
"repo": "bywayboy/RINAPI",
"path": "/code/rinapi/wapi/DeviceContext.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>n_opt_ */ fnObject : CCINT
) -> HGDIOBJ;
}<|fim_prefix|>// repo: bywayboy/RINAPI path: /code/rinapi/wapi/DeviceContext.rs
use super::super::prelude::{
CCINT , HGDIOBJ
};
#[link(name = "Gdi32")]
extern "stdcal<|fim_middle|>l" {
pub fn GetStockObject(
/* _I | code_fim | easy | {
"lang": "rust",
"repo": "bywayboy/RINAPI",
"path": "/code/rinapi/wapi/DeviceContext.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Wombino/plasma-project path: /main.rs
using PyPlot;
# A preliminary file to get started in writing the simulation
# The state of the system will be kept in two arrays. One will specify
# the charge/mass, positions and velocities of Np particles.
# The positions are specified in 1D, while the v... | code_fim | hard | {
"lang": "rust",
"repo": "Wombino/plasma-project",
"path": "/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rhok = fft(world_grid[1:Ng,1])
# Then we obtain the potential for it (solving the Poisson equation).
# The 4pi factor is due to our use of the CGS system
phik = -4*pi*rhok
# This should be zero, so it was probably wise to remove this.
#a0 = phik[1]
phik[1] = 0
... | code_fim | hard | {
"lang": "rust",
"repo": "Wombino/plasma-project",
"path": "/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Now we calculate the potential associated to it.
potential_calculate()
# Let's see
#plot(world_grid[1:end,2])
field_calculate()
#plot(world_grid[10:end-10,3])
xr = linspace(0, L, 10000)
plot(xr, [field_interpolate(x) for x in xr])
end
function test_rho()
#for n ... | code_fim | hard | {
"lang": "rust",
"repo": "Wombino/plasma-project",
"path": "/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Checks that downloading an empty SST returns OK (but cannot be ingested)
download.set_name("test.sst".to_owned());
download.mut_sst().mut_range().set_start(vec![sst_range.1]);
download
.mut_sst()
.mut_range()
.set_end(vec![sst_range.1 + 1]);
let result = impo... | code_fim | hard | {
"lang": "rust",
"repo": "pingyu/tikv",
"path": "/tests/integrations/import/test_sst_service.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pingyu/tikv path: /tests/integrations/import/test_sst_service.rs
"msg: {}; expr: {}",
msg,
stringify!($e)
);
}};
}
#[test]
fn test_upload_sst() {
let (_cluster, ctx, _, import) = new_cluster_and_tikv_import_client();
let data = vec![1; 1024... | code_fim | hard | {
"lang": "rust",
"repo": "pingyu/tikv",
"path": "/tests/integrations/import/test_sst_service.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let buckets = cluster
.pd_client
.get_buckets(ctx.get_region_id())
.unwrap_or_default();
if buckets.meta.keys.len() <= 2 {
std::thread::sleep(std::time::Duration::from_millis(50));
}
return;
}
panic!("region keys is no... | code_fim | hard | {
"lang": "rust",
"repo": "pingyu/tikv",
"path": "/tests/integrations/import/test_sst_service.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tclfs/rust path: /src/librustc_traits/lowering.rs
// Copyright 2018 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
// http://w... | code_fim | hard | {
"lang": "rust",
"repo": "tclfs/rust",
"path": "/src/librustc_traits/lowering.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let trait_ref = tcx.impl_trait_ref(def_id).unwrap();
let trait_ref = ty::TraitPredicate { trait_ref }.lower();
let where_clauses = tcx.predicates_of(def_id).predicates.lower();
let clause = Clause::Implies(where_clauses, trait_ref);
Lrc::new(vec![clause])
}
pub fn dump_program_clause... | code_fim | hard | {
"lang": "rust",
"repo": "tclfs/rust",
"path": "/src/librustc_traits/lowering.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
-> Lrc<Vec<Clause<'tcx>>>
{
if let ImplPolarity::Negative = tcx.impl_polarity(def_id) {
return Lrc::new(vec![]);
}
// Rule Implemented-From-Impl
//
// (see rustc guide)
let trait_ref = t... | code_fim | hard | {
"lang": "rust",
"repo": "tclfs/rust",
"path": "/src/librustc_traits/lowering.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
if let Some(x) = r.get_mut(®) {
match oper {
"dec" => {}
"inc" => {}
_ => { panic!("bad input"); }
}
// if *x > 0 && count_1 == 0 {
// count_1 = count;
// }
// if *x > 1 {
// count_2 = count;
// break;
// }
// *x = *x + 1;
}
}
}
// println!("initi... | code_fim | hard | {
"lang": "rust",
"repo": "nuxeh/AoC-2017",
"path": "/08/process_cpu.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nuxeh/AoC-2017 path: /08/process_cpu.rs
use std::fs::File;
use std::io::prelude::*;
use std::collections::HashMap;
use std::iter::Iterator;
fn main() {
// let filename = "input.txt";
let filename = "test.txt";
let mut f = File::open(filename).expect("file not found");
<|fim_suffix|>// if... | code_fim | hard | {
"lang": "rust",
"repo": "nuxeh/AoC-2017",
"path": "/08/process_cpu.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match Expression::parse(&file_text) {
Ok(res) => println!("{}", res.1.to_rust()),
Err(e) => println!("{}", e),
}
}<|fim_prefix|>// repo: Alkamist/LanguageTranspilerTest path: /src/main.rs
mod instruction;
mod expression;
mod grouping_expression;
mod literal_expression;
mod binary_... | code_fim | medium | {
"lang": "rust",
"repo": "Alkamist/LanguageTranspilerTest",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Alkamist/LanguageTranspilerTest path: /src/main.rs
mod instruction;
mod expression;
mod grouping_expression;
mod literal_expression;
mod binary_expression;
use std::fs;
<|fim_suffix|>fn main() {
let file_text = fs::read_to_string("test_file.txt").unwrap();
match Expression::parse(&fil... | code_fim | easy | {
"lang": "rust",
"repo": "Alkamist/LanguageTranspilerTest",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use crate::mycroft_program::{Database, Foo};
let mut db = Database::new();
db.insert_foo(Foo { arg0: 3 });
db.run_rules_with_timeout(Some(Duration::new(1, 0)));
}<|fim_prefix|>// repo: maurer/mycroft path: /tests/early_termination.rs
use mycroft_macros::mycroft_program;
use std::time::Du... | code_fim | easy | {
"lang": "rust",
"repo": "maurer/mycroft",
"path": "/tests/early_termination.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maurer/mycroft path: /tests/early_termination.rs
use mycroft_macros::mycroft_program;
use std::time::Duration;
use crate::mycroft_program::{IncIn, IncOut};
<|fim_suffix|>#[test]
fn check_timeout() {
use crate::mycroft_program::{Database, Foo};
let mut db = Database::new();
db.inse... | code_fim | medium | {
"lang": "rust",
"repo": "maurer/mycroft",
"path": "/tests/early_termination.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mycroft_program!(
r#"
Foo(u64)
inc_foo: Foo(n_plus_one) <- Foo(n) + inc
"#
);
#[test]
fn check_timeout() {
use crate::mycroft_program::{Database, Foo};
let mut db = Database::new();
db.insert_foo(Foo { arg0: 3 });
db.run_rules_with_timeout(Some(Duration::new(1, 0)));
}<|fim_prefix|>//... | code_fim | easy | {
"lang": "rust",
"repo": "maurer/mycroft",
"path": "/tests/early_termination.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cheme/mydht path: /mydht/src/procs/storeprop.rs
ub init_cache : Box<Fn() -> Result<QC> + Send>,
pub dht_rules : DR,
pub discover : bool,
}
impl<
P : Peer,
RP : Ref<P> + Clone,
V : KeyVal,
VR : Ref<V>,
S : KVStore<V>,
DH : DHTRules,
QC : QueryCache<P,VR,RP>,
> SRef for KVS... | code_fim | hard | {
"lang": "rust",
"repo": "cheme/mydht",
"path": "/mydht/src/procs/storeprop.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cheme/mydht path: /mydht/src/procs/storeprop.rs
TODO currently when forwarding, if no route for forward or failure to forward there is no
//! adjustment of the query : need to include a function call back message on error to
//! MainLoop::ForwardService command
//! TODO non auth may refer to owi... | code_fim | hard | {
"lang": "rust",
"repo": "cheme/mydht",
"path": "/mydht/src/procs/storeprop.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<MC : MyDHTConf> SToRef<OptPeerGlobalDest<MC>> for OptPeerGlobalDest<MC> where
MainLoopSendIn<MC> : Send,
{
#[inline]
fn to_ref(self) -> OptPeerGlobalDest<MC> {
self
}
}
impl<MC : MyDHTConf> SpawnSend<GlobalReply<MC::Peer,MC::PeerRef,KVStoreCommand<MC::Peer,MC::PeerRef,MC::Peer,MC::P... | code_fim | hard | {
"lang": "rust",
"repo": "cheme/mydht",
"path": "/mydht/src/procs/storeprop.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// ## 内存
///
/// Rust程序有3个存放数据的内存区域
///
/// - 数据内存, 对于固定大小和静态的数据,编译器对
/// 这类数据做来很多优化,由于位置已知且固定,因此通常认为编译器
/// 用起来非常快。
/// - 栈内存, 对于在函数中声明为变量的数据。在函数调用期间,内存的
/// 位置不会改变,因为编译器可以优化代码, 所以栈内存数据使用起来非常快。
///
/// - 堆内存,对于在程序运行时创建的数据,次区域中中的数据可以添加、移动
/// 删除、调整大小等。由于它的动态特性,通常认为它使用起来比较慢,但是
/// 它允许更多创造性的内存使用,当数据添加到该... | code_fim | hard | {
"lang": "rust",
"repo": "DaviRain-Su/rust",
"path": "/tour_of_rust/src/chapter3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DaviRain-Su/rust path: /tour_of_rust/src/chapter3.rs
/// #基本数据结构类型
///
///
/// ## 结构体
///
/// 一个struct 就是一些字段的集合
/// 字段是一个与数据结构相关联的数据值。
/// 他的值可以是基本类型或结构体类型
///
/// 它的定义就像一个编译器的蓝图,🛣️编译器如何在内存中布局彼此相邻的字段。
///
/// ```
/// pub struct SeaCreature {
/// // String 是个结构体
/// _animal_type: S... | code_fim | hard | {
"lang": "rust",
"repo": "DaviRain-Su/rust",
"path": "/tour_of_rust/src/chapter3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
REACTION_INFO = Some(get_reaction_info());
};
Ok(Value::from(true))
}
pub fn with_reactions<T, F>(mut f: F) -> T
where
F: FnMut(&[Reaction]) -> T,
{
f(unsafe { REACTION_INFO.as_ref() }
.unwrap_or_else(|| panic!("Reactions not loaded yet! Uh oh!")))
}
pub fn with_specific_heats<T>(f: im... | code_fim | hard | {
"lang": "rust",
"repo": "MarkSuckerberg/auxmos",
"path": "/src/gas/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MarkSuckerberg/auxmos path: /src/gas/types.rs
use std::sync::atomic::{AtomicUsize, Ordering};
use ahash::RandomState;
use std::cell::RefCell;
use crate::reaction::Reaction;
use super::GasIDX;
use dashmap::DashMap;
use std::collections::HashMap;
static TOTAL_NUM_GASES: AtomicUsize = Atomic... | code_fim | hard | {
"lang": "rust",
"repo": "MarkSuckerberg/auxmos",
"path": "/src/gas/types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let hashed_tag = {
let mut hash = WriteHash(H::default());
name.write_to(&mut hash)
.expect("writing to hash won't fail");
hash.0.finalize_fixed()
};
// I started doing this with plans to make this more generic than it is.
... | code_fim | hard | {
"lang": "rust",
"repo": "chappjc/secp256kfun",
"path": "/sigma_fun/src/transcript.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chappjc/secp256kfun path: /sigma_fun/src/transcript.rs
use core::marker::PhantomData;
use crate::{
rand_core::{CryptoRng, RngCore, SeedableRng},
typenum::{
marker_traits::NonZero, type_operators::IsLessOrEqual, PartialDiv, Unsigned, U32, U64,
},
Sigma, Writable,
};
use d... | code_fim | hard | {
"lang": "rust",
"repo": "chappjc/secp256kfun",
"path": "/sigma_fun/src/transcript.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Implements a prover transcript for a 32-byte hash with a rng that takes a 32-byte seed.
impl<S, H, R> ProverTranscript<S> for HashTranscript<H, R>
where
S: Sigma,
H: Update + FixedOutput<OutputSize = U32> + Clone,
R: SeedableRng + CryptoRng + RngCore + Clone,
R::Seed: From<GenericArray... | code_fim | hard | {
"lang": "rust",
"repo": "chappjc/secp256kfun",
"path": "/sigma_fun/src/transcript.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> // let v1 = 1;
// let v2 = 5;
// println!("{:?}", v2);
// println!("{:?}", v1);
}<|fim_prefix|>// repo: ircnelson/rust-presentation path: /examples/03_move.rs
fn main() {
// variable binding
let v1 = vec![1, 2, 3];
// variable re-binding
let v2 = v1;
<|fim_middle|... | code_fim | easy | {
"lang": "rust",
"repo": "ircnelson/rust-presentation",
"path": "/examples/03_move.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // println!("{:?}", v2);
// println!("{:?}", v1);
}<|fim_prefix|>// repo: ircnelson/rust-presentation path: /examples/03_move.rs
fn main() {
// variable binding
let v1 = vec![1, 2, 3];
<|fim_middle|> // variable re-binding
let v2 = v1;
println!("{:?}", v2[0]);
print... | code_fim | medium | {
"lang": "rust",
"repo": "ircnelson/rust-presentation",
"path": "/examples/03_move.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ircnelson/rust-presentation path: /examples/03_move.rs
fn main() {
// variable binding
let v1 = vec![1, 2, 3];
<|fim_suffix|> println!("{:?}", v2[0]);
println!("{:?}", v1[0]);
// let v1 = 1;
// let v2 = 5;
// println!("{:?}", v2);
// println!("{:?}", v1);
... | code_fim | easy | {
"lang": "rust",
"repo": "ircnelson/rust-presentation",
"path": "/examples/03_move.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: futurepaul/piet path: /piet-raqote/examples/basic-raqote.rs
use piet_raqote::RaqoteRenderContext;
use piet_test::draw_test_picture;
use raqote::{DrawOptions, DrawTarget, PathBuilder, SolidSource, Source};
<|fim_suffix|> // TODO: Replace this with clear
draw_target.clear(SolidSource {
... | code_fim | hard | {
"lang": "rust",
"repo": "futurepaul/piet",
"path": "/piet-raqote/examples/basic-raqote.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO: Replace this with clear
draw_target.clear(SolidSource {
r: 0xFF,
g: 0xFF,
b: 0xFF,
a: 0xFF,
});
let mut raqote_context = RaqoteRenderContext::new(&mut draw_target);
draw_test_picture(&mut raqote_context, test_picture_number).unwrap();
draw... | code_fim | hard | {
"lang": "rust",
"repo": "futurepaul/piet",
"path": "/piet-raqote/examples/basic-raqote.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Whoaa512/Eve path: /runtime/src/static_server.rs
use std::io::{Read, Write};
use std::io;
use std::fs::File;
use hyper;
use hyper::net::Fresh;
use hyper::server::{Server, Request, Response};
use hyper::uri::RequestUri;
use hyper::Url;
use hyper::header::ContentType;
use mime::Mime;
use url::Sche... | code_fim | hard | {
"lang": "rust",
"repo": "Whoaa512/Eve",
"path": "/runtime/src/static_server.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file = read_file_bytes(file_path.to_str().unwrap());
let mime: Mime = Mime::from_str(mime_types.mime_for_path(Path::new(file_path))).unwrap();
res.headers_mut().set(ContentType(mime));
let mut res = try!(res.start());
try!(res.write_all(&file));
try!(res.end());
Ok(())
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Whoaa512/Eve",
"path": "/runtime/src/static_server.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pomadgw/susun-empat-kotak path: /wasm-src/src/lib.rs
mod utils;
use js_sys::*;
use wasm_bindgen::prelude::*;
use std::ops::{Index, IndexMut};
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC:... | code_fim | hard | {
"lang": "rust",
"repo": "pomadgw/susun-empat-kotak",
"path": "/wasm-src/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen]
pub fn create_block(block_type: BlockType) -> Matrix {
match block_type {
BlockType::I => create_i_block(),
BlockType::J => create_j_block(),
BlockType::L => create_l_block(),
BlockType::O => create_o_block(),
BlockType::S => create_s_block(),
... | code_fim | hard | {
"lang": "rust",
"repo": "pomadgw/susun-empat-kotak",
"path": "/wasm-src/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Josered30/keylogger-api path: /src/errors/api_error.rs
use actix_rt::blocking::BlockingError;
use actix_web::http::StatusCode;
use actix_web::{HttpResponse, ResponseError};
use serde::Deserialize;
use serde_json::json;
use std::{fmt, io};
#[derive(Debug, Deserialize)]
pub struct ApiError {
... | code_fim | hard | {
"lang": "rust",
"repo": "Josered30/keylogger-api",
"path": "/src/errors/api_error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let error_message = match status_code.as_u16() < 500 {
true => self.message.clone(),
false => "Internal server error".to_string(),
};
return HttpResponse::build(status_code).json(json!({ "message": error_message }));
}
}<|fim_prefix|>// repo: Josered30/k... | code_fim | hard | {
"lang": "rust",
"repo": "Josered30/keylogger-api",
"path": "/src/errors/api_error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bholmesdev/code-advent-cal-2020 path: /day-17/src/main.rs
use std::collections::HashMap;
use std::fs::read_to_string;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum Cube {
A,
I,
}
const DIRECTIONS: [(i32, i32, i32); 26] = [
(-1, -1, -1),
(0, -1, -1),
(1, -1, -1),
... | code_fim | hard | {
"lang": "rust",
"repo": "bholmesdev/code-advent-cal-2020",
"path": "/day-17/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (line_i, line) in split_lines(&file).iter().enumerate() {
for (c_i, c) in line.chars().enumerate() {
plane[cycles][line_i + cycles][c_i + cycles] = match c {
'#' => Cube::A,
_ => Cube::I,
... | code_fim | hard | {
"lang": "rust",
"repo": "bholmesdev/code-advent-cal-2020",
"path": "/day-17/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pop-os/popsicle path: /cli/src/main.rs
//! CLI application for flashing multiple drives concurrently.
#[macro_use]
extern crate anyhow;
#[macro_use]
extern crate cascade;
#[macro_use]
extern crate derive_new;
#[macro_use]
extern crate fomat_macros;
mod localize;
use anyhow::Context;
use async... | code_fim | hard | {
"lang": "rust",
"repo": "pop-os/popsicle",
"path": "/cli/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = self.handle.unbounded_send(Event::Message(
self.id,
if message.is_empty() { kind.into() } else { [kind, " ", message].concat().into() },
));
}
fn finish(&mut self) {
let _ = self.handle.unbounded_send(Event::Finished(self.id));
}
fn... | code_fim | hard | {
"lang": "rust",
"repo": "pop-os/popsicle",
"path": "/cli/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod boolean;
pub mod bootstrap;
pub mod clock;
pub mod clock_priv;
pub mod clock_reply;
pub mod clock_types; // TODO: test
pub mod dyld_kernel;
// pub mod error; // TODO
pub mod exc;
pub mod exception_types;
pub mod kern_return;
pub mod mach_init;
pub mod mach_port;
pub mod mach_types;
pub mod memory_... | code_fim | medium | {
"lang": "rust",
"repo": "10allday-kai/api-daemon",
"path": "/third-party/mach/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 10allday-kai/api-daemon path: /third-party/mach/src/lib.rs
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![cfg_attr(not(feature = "use_std"), no_std)]
#![cfg_attr(feature = "unstable", feature(repr_packed))]
#![cfg_attr(
feature = "cargo-clippy",
allow(
clipp... | code_fim | medium | {
"lang": "rust",
"repo": "10allday-kai/api-daemon",
"path": "/third-party/mach/src/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Raigiku/todo_notes_rust path: /src/infrastructure/presentation/api_actix_web/models/link.rs
use serde::Serialize;
<|fim_suffix|>impl Link {
pub fn new(description: String, uri: String) -> Self {
Self { description, uri }
}
}<|fim_middle|>#[derive(Serialize)]
pub struct Link {
... | code_fim | medium | {
"lang": "rust",
"repo": "Raigiku/todo_notes_rust",
"path": "/src/infrastructure/presentation/api_actix_web/models/link.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Link {
pub fn new(description: String, uri: String) -> Self {
Self { description, uri }
}
}<|fim_prefix|>// repo: Raigiku/todo_notes_rust path: /src/infrastructure/presentation/api_actix_web/models/link.rs
use serde::Serialize;
<|fim_middle|>#[derive(Serialize)]
pub struct Link {
... | code_fim | medium | {
"lang": "rust",
"repo": "Raigiku/todo_notes_rust",
"path": "/src/infrastructure/presentation/api_actix_web/models/link.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.