blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
7f3ccc8811a5b8384dfd89255740c417cbb5cd85 | Rust | pact-foundation/pact-reference | /rust/pact_ffi/src/models/message_pact.rs | UTF-8 | 11,956 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! FFI wrapper for `MessagePact` from pact_matching.
use std::iter::{self, Iterator};
use anyhow::{anyhow, Context};
use libc::c_char;
use pact_models::{Consumer, Provider};
use pact_models::message::Message;
use pact_models::message_pact::MessagePact;
use crate::{as_mut, as_ref, ffi_fn, safe_str};
use crate::util... | true |
324f70d789f97e4d38d9408782d3c1d87031521e | Rust | fahrenkrug/rust_learn_book_chapter_12 | /src/main.rs | UTF-8 | 8,015 | 3.25 | 3 | [] | no_license | use std::env;
use std::process;
use std::thread;
use std::time::Duration;
use minigrep::Config;
use std::collections::HashMap;
use std::hash::Hash;
mod tests {
use super::*;
#[test]
fn call_with_different_values() {
let mut cacher = Cacher::new(|x|x);
let v1 = cacher.value(1);
let... | true |
c417de5bcafa0e2c05df9ea05c9c64a74a030bf6 | Rust | chrisboyce/silkenweb | /crates/dom/src/element_list.rs | UTF-8 | 7,538 | 2.96875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Manage reactive lists of DOM elements.
use std::{
cell::{Ref, RefCell},
collections::{BTreeMap, BTreeSet},
mem,
ops::Bound::{Excluded, Unbounded},
rc::Rc,
};
use silkenweb_reactive::{
clone,
signal::{ReadSignal, Signal},
};
use web_sys as dom;
use crate::{DomElement, Element, ElementBu... | true |
088c8faccfad9cb8fdfaa943fc463a98e6e1a114 | Rust | rouxcaesar/rust | /rust-book/structs.rs | UTF-8 | 658 | 3.125 | 3 | [] | no_license | struct User {
username: String,
email: String,
sign_in_count: u64,
active: bool,
}
fn build_user(username: String, email: String) -> User {
User {
email,
username,
active: true,
sign_in_count: 1,
}
}
fn main() {
let mut u = User {
email: String::fr... | true |
0087e1002b04a160ddfaafea4596e78d5e4c3c64 | Rust | evilpie/crafting-rust-interpreters | /src/object.rs | UTF-8 | 618 | 3.140625 | 3 | [] | no_license | use std::collections::HashMap;
use crate::execute::{VMError, VMResult};
use crate::value::Value;
#[derive(Debug)]
pub struct Object {
fields: HashMap<String, Value>,
}
impl Object {
pub fn new() -> Self {
Object {
fields: HashMap::new(),
}
}
pub fn set(&mut self, name: St... | true |
0e5c76d34ad551ffe6b370ac0446d50395675270 | Rust | GeorgeKT/menhir-lang | /src/span.rs | UTF-8 | 2,093 | 3.1875 | 3 | [
"MIT"
] | permissive | use std::cmp;
use std::fmt;
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct Pos {
pub line: usize,
pub offset: usize,
}
impl Pos {
pub fn new(line: usize, offset: usize) -> Pos {
Pos {
line: line,
offset: offset,
}
}
pu... | true |
f2ea25cc0503f8ddce6746ced9a94e67a9f97a78 | Rust | AxlLind/AxOS | /src/interrupts/gdt.rs | UTF-8 | 2,944 | 2.90625 | 3 | [
"MIT"
] | permissive | use super::DescriptorTablePtr;
use crate::indexable_from_field;
use core::mem::size_of;
// Reference: https://wiki.osdev.org/TSS
#[repr(C, packed)]
pub struct TaskSegmentSelector {
reserved1: u32,
rsp: [u64; 3],
reserved2: u64,
ist: [u64; 7],
reserved3: u64,
reserved4: u16,
io_base_ptr: u16,
}
impl Task... | true |
ad8d3215f7fcf0c9c90e37cb9fd9fc8579e8bd0d | Rust | ywatanabee/learning-systems-programming-in-rust | /chapter3/src/3_5_4/main.rs | UTF-8 | 1,291 | 2.765625 | 3 | [] | no_license | use lib::{
env::temp_file,
image::png::{PngAnalyzer, PngChunk, PngCreator},
};
use std::{
env,
fs::File,
io::{self, Read, Write},
};
fn embed_text_chunk<R: Read>(orig_png_reader: R, text: &str) -> Vec<u8> {
let mut creator = PngCreator::default();
let analyzer = PngAnalyzer::new(orig_png_re... | true |
3efb719cd7f0bfedad8aa70570620c6aa9a8ee92 | Rust | Tanmay000009/LearnRust | /src/vars.rs | UTF-8 | 576 | 3.828125 | 4 | [] | no_license | // Variables hold primitive data or refrences to data
// Variables are immutable by default
// Rust is a block scoped lang
pub fn run() {
let name = "Tanmay";
let mut age = 19;
println!("My name is {}, and I am {}",name,age);
age = 20;
println!("My name is {}, and I am {}",name,age);
// Defin... | true |
2b404e10be2991c9ad71f749c8258700f86f3309 | Rust | johnhurt/caster | /caster_core_model/build.rs | UTF-8 | 3,248 | 2.703125 | 3 | [] | no_license |
use std::fs;
use std::fs::File;
use std::io::prelude::*;
use std::process::Command;
use std::path::Path;
use std::path::PathBuf;
type Result<T> = std::result::Result<T, String>;
fn main() {
let dir_entries = fs::read_dir("proto").unwrap();
let mut lib_content: Vec<String> = Vec::new();
lib_content.push(Stri... | true |
a3eca67dfcd6e33d213b3f95f00d7075774857ae | Rust | kas-gui/kas | /crates/kas-widgets/src/grid.rs | UTF-8 | 15,073 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License in the LICENSE-APACHE file or at:
// https://www.apache.org/licenses/LICENSE-2.0
//! A grid widget
use kas::layout::{DynGridStorage, GridCh... | true |
70818950f993dab68e6a9f781075b7853d7362ce | Rust | hyeonjang/vulkano | /vulkano/src/image/view.rs | UTF-8 | 16,078 | 2.515625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright (c) 2021 The vulkano developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be ... | true |
821fefe71720989ae720350644452f938b56cd24 | Rust | mofanv/veracruz | /sdk/rust-examples/intersection-set-sum/src/main.rs | UTF-8 | 4,657 | 3.640625 | 4 | [
"MIT",
"CC-BY-SA-2.0"
] | permissive | //! Intersection set-sum example
//!
//! ## Context
//!
//! An internet advertising company wants to provide a mechanism by which their customers
//! using the platform can evaluate the effectiveness of their advertising campaigns in a
//! privacy-preserving way. To do this, suppose the advertising company maintains a... | true |
606daf6a059e4aea3f2e705b1d4445e11c77ed31 | Rust | AaronChen0/shadowsocks-rust | /crates/shadowsocks-service/src/local/utils.rs | UTF-8 | 4,429 | 2.578125 | 3 | [
"MIT"
] | permissive | //! Shadowsocks Local Utilities
use std::{io, net::SocketAddr, time::Duration};
use futures::future::{self, Either};
use log::trace;
use shadowsocks::{
config::ServerConfig,
relay::{
socks5::Address,
tcprelay::utils::{copy_from_encrypted, copy_to_encrypted},
},
};
use tokio::{
io::{cop... | true |
dcc3bc54a0e3878d9f8f6edf6d0dcd82e6c9d42f | Rust | lnds/exercism_rust_track | /sieve/src/lib.rs | UTF-8 | 315 | 2.96875 | 3 | [] | no_license | pub fn primes_up_to(upper_bound: u64) -> Vec<u64> {
let limit = upper_bound as usize;
let mut sieve = vec![true; limit + 1];
for i in 2..=limit {
for j in (i + i..=limit).step_by(i) {
sieve[j] = false;
}
}
(2..=upper_bound).filter(|i| sieve[*i as usize]).collect()
}
| true |
e8e32fc5439b1146918c434abfeb9e4ce04934a6 | Rust | MattesWhite/sophia_rs | /sophia/src/graph/inmem/_spo_wrapper.rs | UTF-8 | 5,305 | 2.625 | 3 | [
"CECILL-B",
"LicenseRef-scancode-cecill-b-en"
] | permissive | // this module is transparently re-exported by its parent `graph::inmem`
use std::collections::{HashMap, HashSet};
use std::iter::empty;
use super::*;
use crate::triple::streaming_mode::{ByTermRefs, StreamedTriple};
use sophia_api::graph::{GResultTermSet, GTripleSource};
use sophia_api::term::TTerm;
/// A [`GraphWra... | true |
451a4b99cea171abb5fda29c658f6d9f1db1d846 | Rust | PurpleBooth/readable-name-generator | /src/cli.rs | UTF-8 | 871 | 2.5625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use clap_complete::Shell;
use clap::Parser;
#[derive(Parser, Debug)]
#[clap(author, version, about)]
pub struct Arguments {
/// The separator to use
#[clap(
short,
long,
value_parser,
env = "READABLE_NAME_GENERATOR_SEPARATOR",
default_value = "_"
)]
pub separato... | true |
bb293ae1ac24ed1951b7dfce9d03bd6679dc13e9 | Rust | poletaevvlad/TiddlyProxy | /src/auth.rs | UTF-8 | 5,319 | 3.296875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use serde::{Deserialize, Serialize};
use sha2::{Sha256, Digest};
use generic_array::GenericArray;
use generic_array::typenum::U32;
use base64::{encode_config_buf, decode_config};
pub trait AuthConfig<'a> {
fn secret(&'a self) -> &'a [u8; 32];
}
fn sign_token<'a, T: AuthConfig<'a>>(bytes: &[u8], config: &'a T) -... | true |
931578ef6b3772549a173f178791ac796ad5b529 | Rust | shibumi/in-toto-rs | /src/lib.rs | UTF-8 | 2,438 | 2.78125 | 3 | [
"MIT"
] | permissive | //! This crate provides an API for talking to repositories that implements in-toto
//! # Interoperability
//!
//! It should be noted that historically the TUF spec defined exactly one metadata format and one
//! way of organizing metadata within a repository. Thus, all TUF implementation could perfectly
//! interoperat... | true |
2e00b0dff6d608f10bb1741e084a142fcf71e972 | Rust | dan-sf/advent_of_code | /2018/day4/solution1.rs | UTF-8 | 2,763 | 3.265625 | 3 | [] | no_license | use std::fs;
use std::io;
use std::io::BufRead;
use std::collections::HashMap;
struct Times {
minutes: Vec<i32>,
total: i32,
}
impl Times {
fn new() -> Times {
Times {
minutes: vec![0;60],
total: 0
}
}
}
fn get_parts(line: &str) -> (&str, &str, &str) {
let ... | true |
9bf6e573864234c9a1accd94a7721ace88958687 | Rust | astro/rust-lpc43xx | /src/gpdma/inttcstat/mod.rs | UTF-8 | 8,491 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::INTTCSTAT {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = r" Value of the field"]
pub struct INTTCSTAT0R {
... | true |
fc1c3db5b2237b4e1b1507d1ce92a0c59e1da3fc | Rust | vitiral/rag | /docparse/src/types.rs | UTF-8 | 976 | 3.21875 | 3 | [] | no_license | use std;
#[derive(Debug)]
pub enum ParseError {
Empty,
}
pub type Result<T> = std::result::Result<T, ParseError>;
/// CodeTypes: types that a
#[derive(Debug)]
pub enum CodeTypes {
Fn,
Enum,
Struct,
Trait,
Mod,
}
/// CodeBlock: the unit of documentation
///
/// contains a single unit of doc... | true |
008a60adec4a546e5bec95f430ce39ba21b5cf6c | Rust | TalkTakesTime/red-cod | /src/codebox.rs | UTF-8 | 1,685 | 3.5 | 4 | [
"ISC"
] | permissive | use std::collections::HashMap;
#[derive(Debug, Hash, PartialEq, Eq, Copy, Clone)]
pub struct Pos {
pub x: usize,
pub y: usize,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Instruction {
Noop,
Op(char),
}
#[derive(Debug)]
pub struct Codebox {
code: HashMap<Pos, Instruction>,
width: usiz... | true |
ac8f99c073ef905b01237b387c45608b55f41822 | Rust | mtvu/influxdb_iox | /influxdb_iox/src/commands/database/partition.rs | UTF-8 | 8,476 | 2.53125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! This module implements the `partition` CLI command
use generated_types::google::FieldViolation;
use influxdb_iox_client::{
connection::Connection,
management::{
self, ClosePartitionChunkError, DropPartitionError, GetPartitionError,
ListPartitionChunksError, ListPartitionsError, NewPartitionC... | true |
fbb125efa08df6fb435dbb182847c80b2856be2f | Rust | tsugitta/atcoder | /snippets/rs/src/binary_search.rs | UTF-8 | 1,517 | 3.96875 | 4 | [] | no_license | use std::cmp::Ordering;
#[snippet = "BinarySearch"]
pub trait BinarySearch<T> {
fn lower_bound(&self, x: &T) -> usize;
fn upper_bound(&self, x: &T) -> usize;
}
#[snippet = "BinarySearch"]
impl<T: Ord> BinarySearch<T> for [T] {
fn lower_bound(&self, x: &T) -> usize {
let mut low: isize = -1;
... | true |
5bfd37a4bb7410369de320d45255e8bfe9b0819e | Rust | sargarass/Ray-Tracing-in-One-Weekend-Rust | /src/ray.rs | UTF-8 | 871 | 3.453125 | 3 | [] | no_license | use crate::point::Point3;
use crate::vector::{Len, Normalize, Vec3};
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Ray {
pub orig: Point3,
pub dir: Vec3,
}
impl Ray {
pub fn new(origin: Point3, direction: Vec3) -> Ray {
assert!(
Vec3::almost_eq(direction.normalize(), direction, 5... | true |
7480680cab538820098ce9786b89797ee60b15d1 | Rust | dennisss/dacha | /pkg/file/src/local/path.rs | UTF-8 | 19,206 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | use alloc::{
borrow::ToOwned,
string::{String, ToString},
};
use core::{borrow::Borrow, fmt::Debug, ops::Deref};
use std::ffi::OsStr;
use common::errors::*;
/// TODO: Support windows.
const SEGMENT_DELIMITER: char = '/';
/*
Differences between this and the 'std' Path
- All methods here are purely string mani... | true |
42ef8c98fe2649a8c608ba26f1160108b9ed6a15 | Rust | ssfivy/adventofcode2019 | /aoc05/src/cpu.rs | UTF-8 | 6,695 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::convert::TryInto;
fn get_opc(instruction: i32) -> u8 {
return (instruction % 100) as u8;
}
// note: param is 1-indexed
fn get_pmode(instruction: i32, param: u8) -> u8 {
let mut insc: u32 = (instruction / 100) as u32;
for _dummy in 1..param {
insc /= 10;
}
return (insc % 10) as u8;... | true |
7267ccff6eb0e96825f9669f9e04102eb4ee478b | Rust | redirectionio/libredirectionio | /tests/redirectionio_router_test.rs | UTF-8 | 606,011 | 2.515625 | 3 | [
"MIT"
] | permissive | extern crate redirectionio;
#[rustfmt::skip]
mod generated_tests {
use redirectionio::router::{Router, RouterConfig, Trace};
use redirectionio::api::Rule;
use redirectionio::http::{Request, Header, PathAndQueryWithSkipped};
use redirectionio::action::Action;
fn setup_00_common_rules() -> Router<Rule> {
let confi... | true |
7661247e9f162f0470f8729047583040060379da | Rust | enso-org/enso | /lib/rust/parser/src/syntax/token.rs | UTF-8 | 20,748 | 3.578125 | 4 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | //! A lexical token is a string with an assigned and thus identified meaning. Each token remembers
//! its source code and can be printed back. It also contains information about the offset to the
//! previous token if any.
//!
//! The [`Token`] structure has a signature of [`Token<'s, T>`], where [`T`] is the variant ... | true |
573497f11657df2f1d6b9bf7d96a75c98f2a15a9 | Rust | galfudim/project-euler | /src/p_six.rs | UTF-8 | 311 | 3.109375 | 3 | [] | no_license | pub(crate) fn sum_squares(limit: i64) -> i64 {
let mut sum: i64 = 0;
for i in 1..=limit {
sum += i*i;
}
return sum;
}
pub(crate) fn square_sums(limit: i64) -> i64 {
let mut sum: i64 = 0;
for i in 1..=limit {
sum += i;
}
let square = sum*sum;
return square;
} | true |
9ec8d2060d1e6afd05dfdece74d5b550d7bd11ad | Rust | ArunGust/sauron | /crates/sauron-node-macro/tests/style_in_node.rs | UTF-8 | 597 | 3 | 3 | [
"MIT"
] | permissive | use sauron::prelude::*;
use sauron::{node, Node, Render};
#[test]
fn style_should_be_valid() {
let node1: Node<()> = node!(<div style="border:1px solid green;"></div>);
let expected = r#"<div style="border:1px solid green;"></div>"#;
let mut buffer = String::new();
node1.render(&mut buffer).expect("mus... | true |
e2f157b327666be8b1a786e7d1ff1bcecd9ff2f1 | Rust | boa-dev/boa | /boa_parser/src/lexer/mod.rs | UTF-8 | 13,806 | 3.1875 | 3 | [
"MIT",
"Unlicense"
] | permissive | //! Boa's lexical analyzer(Lexer) for ECMAScript source code.
//!
//! The Lexer splits its input source code into a sequence of input elements called tokens,
//! represented by the [Token] structure. It also removes
//! whitespace and comments and attaches them to the next token.
//!
//! This is tightly coupled with th... | true |
896274654f916ce0114859d36492addb25e50dc9 | Rust | iChinxu/server_tan | /src/xml.rs | UTF-8 | 4,453 | 2.84375 | 3 | [
"MIT"
] | permissive | use chrono;
use quick_xml::events::{BytesEnd, BytesStart, BytesText, Event};
use quick_xml::{Reader, Writer};
use std::io::Cursor;
#[derive(Debug, Deserialize, Clone, Serialize)]
pub struct UniversMessage {
pub from: Option<String>,
pub to: Option<String>,
pub content: Option<String>,
pub msg_type: Op... | true |
9576d5fff4eaf8c54a30a260d6f1390226ed8681 | Rust | feifeiq/example.rs | /src/list.rs | UTF-8 | 1,526 | 3.515625 | 4 | [] | no_license | #![feature(box_syntax)]
use List::{Cons,Nil};
use std::fmt::{Display,Result,Formatter};
use std::mem;
#[derive(Debug)]
enum List<T> {
Nil,
Cons(T, Box<List<T>>)
}
impl<T:Display> List<T> {
fn new() -> Box<List<T>> {
Box::new(List::Nil)
}
fn prepend(self: Box<List<T>>, x: T) -> Box<Lis... | true |
3174147c0d4a1dbff29218fa8d7c25813f66c187 | Rust | cassiemeharry/pf2e-csheet | /pf2e-csheet-shared/src/items.rs | UTF-8 | 757 | 2.625 | 3 | [] | no_license | #[cfg(test)]
use proptest_derive::Arbitrary;
use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(test, derive(Arbitrary))]
pub enum ItemType {
Any,
Armor,
Shield,
Weapon,
Other,
}
impl Default... | true |
eecc8daab286d6b24fd8c686d8550a0f56e3619d | Rust | kateinoigakukun/wasminspect | /crates/debugger/src/commands/expression.rs | UTF-8 | 3,374 | 2.53125 | 3 | [
"MIT"
] | permissive | use crate::dwarf::{FrameBase, WasmLoc};
use super::command::{Command, CommandContext, CommandResult};
use super::debugger::Debugger;
use anyhow::{anyhow, Context, Result};
pub struct ExpressionCommand {}
impl ExpressionCommand {
pub fn new() -> Self {
Self {}
}
}
use structopt::StructOpt;
#[derive(St... | true |
51d1e8f34496723c4dfc76ced40484f65eee5e7a | Rust | 9999years/gcc-emu | /src/main.rs | UTF-8 | 3,093 | 3.109375 | 3 | [] | no_license | extern crate regex;
extern crate rand;
use std::process::Command;
use std::collections::HashSet;
use std::fs::File;
use std::io::Read;
use std::ops::Range;
use std::thread;
use std::time::Duration;
use rand::{thread_rng, Rng};
use regex::Regex;
const NM_PREFIX_LEN: usize = 19;
const NM_OFFSET_LEN: usize = 16;
fn fr... | true |
49103cb603611ae641a614570a027b504bc6004e | Rust | rust-lang/glacier | /fixed/86850.rs | UTF-8 | 386 | 2.734375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![feature(generic_const_exprs)]
#![allow(incomplete_features)]
use core::marker::PhantomData;
pub trait Foo {
const SIZE: usize;
}
pub struct Bar<T>(PhantomData<T>);
impl<T: Foo> Bar<T> {
pub fn new(array: [(); T::SIZE]) -> Self {
Self(PhantomData)
}
pub fn bar(self) -> Bar<T>
where
... | true |
940a413831d1a0d81ac58b47212f2d43459c79f1 | Rust | daniel5151/compressed-emoji-shortcodes | /rust-phf/phf_codegen/src/lib.rs | UTF-8 | 4,635 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
use std::fmt;
use phf_generator::HashState;
use phf_shared::checksum;
/// A builder for the `phf::CompressedMap` type.
pub struct Map<'a> {
datum_len: usize,
keys: Vec<&'a str>,
values: Vec<&'a str>,
path: String,
}
impl<'a> Map<'a> {
/// Creates a new `phf::Compres... | true |
a58e7b0b511d255eb8bead139eb54e5e2ce5efaa | Rust | tverghis/aoc_2019 | /rust/day_03/src/circuit/line.rs | UTF-8 | 2,867 | 3.71875 | 4 | [] | no_license | use crate::circuit::Point;
/// Lines can only be vertical or horizontal, since the direction of movement is always at
/// 90-degree angles.
#[derive(Debug, PartialEq)]
enum LineOrientation {
Vertical,
Horizontal,
}
#[derive(Debug, PartialEq)]
pub struct Line {
p1: Point,
p2: Point,
}
impl Line {
... | true |
efb38d272620bfbdb431e0980745a3ebbd2868e8 | Rust | myuon/atcoder | /abc087/src/bin/d.rs | UTF-8 | 2,028 | 2.78125 | 3 | [] | no_license | use algo::*;
use std::collections::HashMap;
fn solve(n: usize, m: usize, lrds: Vec<[i32; 3]>) -> bool {
let mut indices = HashMap::new();
for [l, r, _] in &lrds {
indices.insert(l, 0);
indices.insert(r, 0);
}
let indices_clone = indices.clone();
let mut xs = indices_clone.keys().co... | true |
4ea26940709e8270345fa682c1ad1d65c4397a91 | Rust | kichristensen/k8s-openapi-codegen | /k8s-openapi/src/api/core/v1/node_selector_requirement.rs | UTF-8 | 951 | 2.765625 | 3 | [] | no_license | // Generated from definition io.k8s.api.core.v1.NodeSelectorRequirement
/// A node selector requirement is a selector that contains values, a key, and an operator that relates the key and values.
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct NodeSelectorRequirement {
/// The label key that the selec... | true |
644344e3b42cd05bc3b993222f101a64c61e1ae5 | Rust | thewhitewizard/timelock-1 | /src/info.rs | UTF-8 | 3,533 | 2.90625 | 3 | [
"MIT"
] | permissive | use crate::core::*;
use crate::hash;
use crate::puzzlefile;
use crate::workfile;
use clap::ArgMatches;
use linreg::linear_regression;
use std::path::Path;
use std::time::Duration;
pub fn decide_rate() -> f64 {
let x: Vec<i32>;
if cfg!(debug_assertions) {
x = vec![
10000, 10000, 10000, 10000... | true |
c5d5590f42d0200b6bcae9c7a53762689bf7770f | Rust | rust-lang/rust | /tests/ui/pattern/usefulness/doc-hidden-fields.rs | UTF-8 | 648 | 2.625 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // aux-build:hidden.rs
extern crate hidden;
use hidden::HiddenStruct;
struct InCrate {
a: usize,
b: bool,
#[doc(hidden)]
im_hidden: u8
}
fn main() {
let HiddenStruct { one, two } = HiddenStruct::default();
//~^ pattern requires `..` due to inaccessible fields
let HiddenStruct { one } = ... | true |
c4f0a6d0d0a3553dcb5e8358c4ea596a21f8fffb | Rust | keyko-io/xain-fl | /rust/src/common/settings.rs | UTF-8 | 1,488 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use serde::de::{self, Deserializer, Visitor};
use std::fmt;
use tracing_subscriber::filter::EnvFilter;
#[derive(Debug, Deserialize)]
pub struct LoggingSettings {
// Note that we don't hide this behind a
// #[cfg(feature="telemetry")] because we want the config files to
// keep working independently of the ... | true |
0abb4c4667e8e7961a3e50727621a49fd5ae8d4a | Rust | bokuweb/docx-rs | /docx-core/src/reader/delete.rs | UTF-8 | 2,467 | 2.65625 | 3 | [
"MIT"
] | permissive | use std::io::Read;
use std::str::FromStr;
use xml::attribute::OwnedAttribute;
use xml::reader::{EventReader, XmlEvent};
use super::*;
impl ElementReader for Delete {
fn read<R: Read>(
r: &mut EventReader<R>,
attrs: &[OwnedAttribute],
) -> Result<Self, ReaderError> {
let mut del = Dele... | true |
a2e89f35a4eb35b94c2bdbf67ee3ea15f9380cce | Rust | sgeisler/nym | /common/socks5/proxy-helpers/src/read_delay_loop.rs | UTF-8 | 2,779 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Nym Technologies SA
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... | true |
a512083418ee2d748cfd17f7f0e9580d06fcbaba | Rust | GopherSecurity/plonky | /src/serialization.rs | UTF-8 | 12,318 | 2.5625 | 3 | [] | no_license | use crate::{AffinePoint, Curve, Field, TweedledumBase, Bls12377Base, Bls12377Scalar, TweedledeeBase, PallasBase, VestaBase};
use serde::de::Error as DeError;
use serde::de::Visitor;
use serde::ser::Error as SerdeError;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
use std::io::{Error, Err... | true |
2ff4c97faa36a1199760d920b0e05874d4edda33 | Rust | magiclen/cidr-utils | /src/cidr/v4/ipv4_cidr.rs | UTF-8 | 9,306 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::{
cmp::Ordering,
convert::TryFrom,
fmt::{self, Debug, Display, Formatter},
net::Ipv4Addr,
str::FromStr,
};
use once_cell::sync::Lazy;
use regex::Regex;
#[cfg(feature = "serde")]
use serde::de::{Deserialize, Deserializer, Error as DeError, Visitor};
#[cfg(feature = "serde")]
use serde::ser:... | true |
8c3eed5c0a470916a6fdff0fb08c2708936f32f5 | Rust | dbcfd/openapi-context | /src/drop_context.rs | UTF-8 | 3,131 | 3.359375 | 3 | [
"Apache-2.0"
] | permissive | //! Hyper service that adds a context to an incoming request and passes it on
//! to a wrapped service.
use crate::ContextualPayload;
use hyper::{Body, Request};
use std::marker::PhantomData;
use std::task::{Context, Poll};
/// Middleware wrapper service that drops the context from the incoming request
/// and passes... | true |
1636ed202410e7128ad4715a6e2d377f21bac929 | Rust | liov/hoper | /_lang/rust/hoper/src/bin/btree.rs | UTF-8 | 320 | 3.046875 | 3 | [] | no_license | use std::collections::BTreeSet;
fn main() {
let mut set: BTreeSet<usize> = [3, 1, 2].iter().cloned().collect();
let mut set_iter = set.iter();
let mut i = 0;
while let Some(t) = set_iter.next() {
println!("{:?}", set);
i+=1;
set.insert(i);
set_iter = set.iter();
}
}
| true |
0ead200b5e3e900f38ae6ba2c9ea7474d711ef4a | Rust | Redfox/rust-api | /src/db/users.rs | UTF-8 | 1,306 | 2.8125 | 3 | [] | no_license | use crate::models::user::User;
use crate::schema::users;
use crypto::scrypt::{ scrypt_check, scrypt_simple, ScryptParams };
use diesel::pg::PgConnection;
use diesel::prelude::*;
use diesel::result::{DatabaseErrorKind, Error};
#[derive(Insertable)]
#[table_name = "users"]
pub struct NewUser<'a> {
pub username: &'a st... | true |
9011265b6b2c78150715a33ef529046d9ad2e79f | Rust | minus3theta/contest | /atcoder/arc/067/d.rs | UTF-8 | 853 | 3.03125 | 3 | [] | no_license | #[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::cmp;
use std::collections::LinkedList;
#[allow(dead_code)]
fn getline() -> LinkedList<String> {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok().unwrap();
s.split(' ').map(|x| x.trim().to_string()).collect::<LinkedLis... | true |
0a1f78cad00268c962b6464f6c737e0d9e14bda2 | Rust | garebareDA/koto | /src/interpreter/ifs.rs | UTF-8 | 841 | 2.6875 | 3 | [] | no_license | use super::super::ast::asts;
use super::interpreters;
use super::function;
use super::variable;
pub struct If {
pub result: asts::Types,
pub ifs: Vec<asts::Types>
}
impl If {
pub fn new(result: &asts::Types, ifs: &Vec<asts::Types>) -> If {
If{
result: result.clone(),
ifs: i... | true |
b4b6ac7afa033bd4527d95a84bd92de5b565d3da | Rust | SeriousRedCat/fuzzy-rust | /src/lib/norm.rs | UTF-8 | 220 | 2.671875 | 3 | [] | no_license | pub trait NormTrait {
fn compute(&self, left: f64, right: f64) -> f64;
}
#[derive(Default)]
pub struct Norm {}
impl NormTrait for Norm {
fn compute(&self, _left: f64, _right: f64) -> f64 {
1f64
}
}
| true |
e1ea137ebd6e3daeda7361e6218050f2facb431b | Rust | OrangeBacon/opengl-rust | /lib/engine/src/bound.rs | UTF-8 | 1,479 | 2.90625 | 3 | [
"MIT"
] | permissive | use nalgebra_glm as glm;
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Default)]
pub struct Bounds {
pub min_x: f32,
pub min_y: f32,
pub min_z: f32,
pub max_x: f32,
pub max_y: f32,
pub max_z: f32,
}
impl Bounds {
pub fn new_nan() -> Self {
Self {
min_x: f32::NAN,... | true |
b258ad6c8cbaedc7ce3d739e070d44535331d23d | Rust | osa1/tiny | /crates/term_input_macros/src/tree.rs | UTF-8 | 2,896 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::syntax::*;
use proc_macro2::TokenStream;
use quote::quote;
use quote::TokenStreamExt;
use std::collections::HashMap;
struct Node {
idx: usize,
value: Option<syn::Expr>,
next: HashMap<u8, Node>,
}
impl Node {
fn new(idx: usize) -> Self {
Node {
idx,
value: No... | true |
5c4aea4b7b218a33c27a600c773e76f9f531182f | Rust | juliencrn/hello_grep | /src/cli.rs | UTF-8 | 2,358 | 2.984375 | 3 | [
"MIT"
] | permissive | use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(
name = "hello_grep",
about = "A command line mini grep clone app written in Rust."
)]
pub struct CommandLineArgs {
pub pattern: String,
#[structopt(parse(from_os_str))]
pub path: Vec<PathBuf>,
#[structo... | true |
24dca12ad25c887ad8c0aac579623e1732119b3e | Rust | munckymagik/redis-clone | /byte_glob/tests/byte_glob_tests.rs | UTF-8 | 5,041 | 3.21875 | 3 | [] | no_license | use byte_glob::*;
#[test]
fn test_empty_inputs() {
assert!(glob(b"", b""));
assert!(!glob(b"a", b""));
assert!(!glob(b"", b"a"));
}
#[test]
fn test_literal_characters() {
assert!(glob(b"a", b"a"));
assert!(!glob(b"a", b"b"));
}
#[test]
fn test_literal_characters_different_lengths() {
// When ... | true |
299df5808d765db6a468324f4ef22e416cbf169f | Rust | scott113341/advent_of_code_2020 | /day_09/src/main.rs | UTF-8 | 3,401 | 3.8125 | 4 | [] | no_license | use std::collections::{BTreeMap, HashSet};
pub struct Data {
pub preamble_size: usize,
pub numbers: Vec<usize>,
}
type SumMap = BTreeMap<(usize, usize), usize>;
fn main() {
let input = include_str!("input.txt")
.trim()
.split("\n")
.map(|s| s.parse().unwrap())
.collect();
... | true |
d36f302a960b29f95c4346adac2591e72accbac0 | Rust | Hugobros3/nes | /src/mappers/mapper0.rs | UTF-8 | 2,281 | 2.8125 | 3 | [] | no_license | use crate::cartdrige::Cartdrige;
use crate::ines_loader::INesHeaderInfo;
use std::io::{Read, BufReader};
pub fn create_mapper0_cartdrige<T: Read>(header: INesHeaderInfo, reader: &mut BufReader<T>) -> Box<dyn Cartdrige> {
let mut prg_rom = Vec::<[u8;16384]>::new();
for i in 0..header.prg_pages {
let mut... | true |
8993c3e1d2f372ae3785120023517bfd6732db14 | Rust | hgm-king/RustPlayground | /src/linked_lists/hold.rs | UTF-8 | 5,237 | 3.734375 | 4 | [] | no_license | use std::mem;
/* List a = Empty | Elem a (List a) */
/*
* List is here to hold the entire structure in order to have a nice pointer.
* A list consists of a link, which is explained later.
* Reasoning behind this is that any given sub list can be cast as a List,
* which is exactly the inked list behavior we want
... | true |
01c434e6b8a22c25b22167f4f158d3c60d950a0b | Rust | frankplus/three-d | /src/objects/vertices.rs | UTF-8 | 2,905 | 2.9375 | 3 | [
"MIT"
] | permissive |
use crate::*;
pub struct Vertices {
program: Program,
instance_buffer: VertexBuffer,
ball_index_buffer: ElementBuffer,
ball_vertex_buffer: VertexBuffer,
no_vertices: u32,
pub color: Vec3,
pub diffuse_intensity: f32,
pub specular_intensity: f32,
pub specular_power: f32,
pub ball... | true |
b2825a8cfd60d7a79c5c77522da1daefae4dce1e | Rust | bot190/mc_pointy | /src/replacement_definitions.rs | UTF-8 | 3,639 | 3.25 | 3 | [
"MIT"
] | permissive | pub mod replacements {
use serde::{Deserialize, Serialize, Serializer, Deserializer};
use std::collections::HashMap;
// This contains replacement information for a block id
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum ValOrAny {
Val(i64),
Any
}
impl Serialize... | true |
e454c6071a15eef49cc34a0376deeba53091282e | Rust | jreyes33/oauth1-header | /tests/smoke.rs | UTF-8 | 961 | 2.90625 | 3 | [
"CC0-1.0"
] | permissive | use oauth1_header::http::Method;
use oauth1_header::Credentials;
use std::collections::HashMap;
// Placing tests here instead of in the same `src` files allows us to test as
// if we were consumers of the crate.
#[test]
fn it_works() {
let mut params = HashMap::new();
params.insert("foo", "bar");
let cred... | true |
5e07a27331ea6538b605a2d2ffb723cbf1510478 | Rust | zacharydenton/raytracer | /src/geometry.rs | UTF-8 | 2,494 | 3.40625 | 3 | [] | no_license | extern crate cgmath;
use cgmath::Vector3;
use cgmath::prelude::*;
use ray::Ray;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Geometry {
Sphere { center: Vector3<f64>, radius: f64 },
}
impl Geometry {
pub fn intersection(&self, ray: Ray, tmin: f64, tmax: f64) -> Option<f64> {
match self {
... | true |
392b9858e9d579ed042998cee8db6eb827c6e3e5 | Rust | andrewcsmith/phoneme_morpher | /src/feeder.rs | UTF-8 | 2,540 | 2.703125 | 3 | [] | no_license | use statfeed::Statfeed;
use soundsym::{Sound, SoundSequence};
use std::rc::Rc;
use std::sync::Arc;
use std::f64;
pub struct Feeder {
pub sf: Statfeed<Arc<Sound>>,
pub phonemes_per_line: usize,
current_line: usize
}
impl Feeder {
pub fn new(sounds: Vec<Arc<Sound>>, phonemes_per_line: usize, lines: usi... | true |
7aa66eea1b1bf5e22020cd827a2b999eae6a9ca8 | Rust | kuviman/codevisual | /codevisual/src/window/cursor.rs | UTF-8 | 1,791 | 2.75 | 3 | [
"MIT"
] | permissive | use *;
pub enum CursorType {
Default,
Pointer,
Drag,
}
impl Window {
pub fn set_cursor_type(&self, cursor_type: CursorType) {
#[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))]
{
let cursor_type = match cursor_type {
CursorType::Default => "initial",... | true |
1780e0d16c8a745092981fc6c430f3cd8e562440 | Rust | prisma/prisma-engines | /query-engine/connector-test-kit-rs/query-engine-tests/tests/new/regressions/prisma_10098.rs | UTF-8 | 1,490 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | use query_engine_tests::*;
#[test_suite(schema(schema), only(MongoDb))]
mod mongodb {
use indoc::indoc;
fn schema() -> String {
let schema = indoc! {
r#"
model Course {
id String @id @default(auto()) @map("_id") @test.ObjectId
rating Float @defau... | true |
c9e065371d4405fe4dfe191af4f2f81a9fca80ff | Rust | prisma/prisma-engines | /query-engine/prisma-models/src/projections/model_projection.rs | UTF-8 | 4,150 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use crate::{Field, FieldSelection, ScalarFieldRef, SelectedField, SelectionResult, TypeIdentifier};
use itertools::Itertools;
use psl::schema_ast::ast::FieldArity;
/// Projection of a `Model`. A projection is a (sub)set of fields of a model.
/// There can only ever be fields of one model contained in a particular `Mod... | true |
2def95a2a1cd2771870a7f92402d524499021c59 | Rust | baitcenter/mori | /binary_search_tree/src/lib.rs | UTF-8 | 14,610 | 3.5625 | 4 | [
"MIT"
] | permissive | use std::rc::Rc;
use std::cell::RefCell;
use std::cell::Ref;
use std::collections::VecDeque;
#[derive(Debug)]
pub struct Node<V: Clone>(Rc<RefCell<RawNode<V>>>);
impl<V: Clone> Node<V> {
pub fn new(key: usize, value: V) -> Self {
let node = Rc::new(RefCell::new(RawNode {
key,
value... | true |
ba047c6c3b8924a21a420bd90daab749e1d34a3e | Rust | yeliknewo/rrl | /utils/src/ortho_helper.rs | UTF-8 | 1,527 | 2.90625 | 3 | [] | no_license | use ::GfxCoord;
use cgmath::{Matrix4, Ortho};
#[derive(Clone, Debug)]
pub struct OrthographicHelper {
aspect_ratio: GfxCoord,
ortho: Ortho<GfxCoord>,
}
impl OrthographicHelper {
pub fn new(aspect_ratio: GfxCoord, left: GfxCoord, right: GfxCoord, near: GfxCoord, far: GfxCoord) -> OrthographicHelper {
... | true |
7459e80d09442cf3902234d3a38b02377dd5e1c0 | Rust | jeanpehk/rust-v | /src/tests.rs | UTF-8 | 18,421 | 2.859375 | 3 | [] | no_license | #[cfg(test)]
mod unit_tests {
#[cfg(test)]
mod core_tests {
use crate::init;
use crate::eval;
#[test]
fn addi_sp_sp_minus_one() {
let mut core = init();
eval(0xfff10113, &mut core);
assert_eq!(-1, core.regs[2]);
}
#[test]
... | true |
c541b13bb55632e96ec5062f514204ed0d99ed6c | Rust | tomaka/eui | /src/predefined/empty.rs | UTF-8 | 327 | 2.765625 | 3 | [] | no_license | use Alignment;
use Layout;
use Widget;
/// An empty widget.
pub struct Empty;
impl Empty {
/// Builds an `Empty`.
#[inline]
pub fn new() -> Empty {
Empty
}
}
impl Widget for Empty {
#[inline]
fn build_layout(&self, _: f32, _: Alignment) -> Layout {
Layout::Shapes(Vec::new())
... | true |
adc52cd72e566e2ed3d533dadd0bc79374324fe9 | Rust | deusletum/teensy4-rs | /examples/rtic/src/bin/rtic_usb_echo.rs | UTF-8 | 2,536 | 2.84375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! A USB example that echos data back to the USB host
//!
//! The example shows how you can use the `PollStatus`
//! from the `usb::poll` function to understand if data
//! is available from the host. Every echo causes the
//! LED to toggle.
#![no_std]
#![no_main]
use bsp::hal::ral::usb::USB1;
use teensy4_bsp as bsp... | true |
d7cbf3160aa7ffc1b364d42056c67e8d1bce42c5 | Rust | ivfranco/notes | /Dragon_Book/chapter_11/loop_nest/src/utils.rs | UTF-8 | 320 | 3.1875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | pub fn gcd(seq: &[i32]) -> i32 {
assert!(!seq.is_empty());
seq.iter()
.skip(1)
.fold(seq[0].abs(), |g, n| gcd_euclid(g, n.abs()))
}
fn gcd_euclid(a: i32, b: i32) -> i32 {
if a < b {
gcd_euclid(b, a)
} else if b == 0 {
a
} else {
gcd_euclid(b, a % b)
}
}
| true |
a8c7cd198b8cd6710eb08c6f08ba633ddf27398a | Rust | osaut/rustic_cells | /agent.rs | UTF-8 | 5,043 | 3.109375 | 3 | [
"BSD-2-Clause"
] | permissive |
extern mod extra;
use geometry::Point;
use std::rand;
use std::num::{pow,ln};
use std::f64;
mod geometry;
//
// Cellule
//
#[deriving(Clone)]
pub struct Cell {
center: Point,
id: uint,
radius: f64,
velocity: Point,
acc: Point,
generation: uint,
age: f64,
t_dup: f64
}
impl Cell {
... | true |
ae44bb6b4d0205b774bd7616f1a2a1d57f564d99 | Rust | TGElder/rust | /isometric/src/events.rs | UTF-8 | 703 | 2.6875 | 3 | [] | no_license | use commons::async_channel::Sender;
use engine::{Command, Event};
use futures::executor::block_on;
use std::sync::Arc;
pub trait EventHandler: Send {
fn handle_event(&mut self, event: Arc<Event>) -> Vec<Command>;
}
pub trait EventConsumer: Send {
fn consume_event(&mut self, event: Arc<Event>);
}
pub struct ... | true |
415bc5001ed0c5f91ab8f0feb40ee471a34f5d29 | Rust | novoru/GBR | /src/core/ram.rs | UTF-8 | 389 | 3.015625 | 3 | [
"MIT"
] | permissive | use crate::core::io::Io;
const RAM_SIZE: usize = 8192;
pub struct Ram {
ram: [u8; RAM_SIZE],
}
impl Ram {
pub fn new() -> Self {
Ram {
ram: [0; RAM_SIZE]
}
}
}
impl Io for Ram {
fn read8(&self, addr: usize) -> u8 {
self.ram[addr]
}
fn write8(&mut ... | true |
528333f9f0020818215992edd031e4be6c323e67 | Rust | do4gr/congenial-barnacle | /src/main.rs | UTF-8 | 648 | 2.578125 | 3 | [] | no_license | use clap::{App, Arg};
use engine_lib::core_logic;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let matches = App::new("Transaction Engine")
.version("0.1")
.author("do4gr")
.about("Processes transactions input as csv, outputs client account states to... | true |
02659c6538ea2d2d395fbbafcaaea1467e002226 | Rust | zaeleus/noodles | /noodles-vcf/src/header/record/key.rs | UTF-8 | 5,293 | 2.921875 | 3 | [
"MIT"
] | permissive | //! VCF header record key.
pub mod other;
pub use self::other::Other;
use std::fmt;
/// VCF header record file format key.
pub const FILE_FORMAT: Key = Key::Standard(Standard::FileFormat);
/// VCF header record info key.
pub const INFO: Key = Key::Standard(Standard::Info);
/// VCF header record filter key.
pub co... | true |
03e5f011f9b70ceadf124bda4d6d30f3bfa7d1b6 | Rust | collinsmith/rust-tutorials | /menu/src/main.rs | UTF-8 | 752 | 3 | 3 | [] | no_license | //use std::io::Write;
mod menu;
use menu::Menu;
fn main() {
let mut menu = Menu::new_named(String::from("Main"));
menu.add_blank("Option");
menu.add_sub_menu(Menu::new_named(String::from("Submenu")));
// menu.println();
//
// let mut input = String::new();
// loop {
// print!("Enter and op... | true |
83a4b627abf8acb5f4e8d80b43787ed11f805f5d | Rust | nju33-com/get-started-diesel-insert | /src/main.rs | UTF-8 | 618 | 2.65625 | 3 | [] | no_license | use diesel::pg::PgConnection;
use diesel::prelude::*;
use get_started_diesel_insert::{schema, NewUser, User};
const DATABASE_URL: &'static str = "postgres://postgres:@localhost:5432";
fn main() {
let connection =
PgConnection::establish(DATABASE_URL).expect(&format!("Error connecting to {}", DATABASE_URL));
... | true |
ac4f1563050bd01c929e2ed25dd8ee7f79d71f27 | Rust | diesel-rs/diesel | /diesel/src/pg/types/date_and_time/quickcheck_impls.rs | UTF-8 | 1,769 | 2.84375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate quickcheck;
use self::quickcheck::{Arbitrary, Gen};
use super::{PgDate, PgInterval, PgTime, PgTimestamp};
// see https://www.postgresql.org/docs/current/datatype-datetime.html
// for the specific limits
impl Arbitrary for PgDate {
fn arbitrary(g: &mut Gen) -> Self {
const MIN_DAY: i32 = (-4... | true |
1468e00ac86a0d33be1a59adf5e689af463f970f | Rust | theLastOfCats/git-secret-rust | /src/logic/fsdb.rs | UTF-8 | 689 | 3.03125 | 3 | [] | no_license | use ini::Ini;
use crate::{consts, types};
/// Returns the existing file system database.
fn open() -> types::Result<Ini> {
Ok(Ini::load_from_file(consts::SecretDir::PathsMapping.path())?)
}
/// Appends a sequence of files to the file system database.
/// We store our files under `[git-secret]` section.
/// The for... | true |
e095daf3b2bb544e8ad7ce7943dc8ce387049d33 | Rust | saghm/rural | /src/main.rs | UTF-8 | 2,646 | 2.53125 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate lazy_static;
mod client;
mod error;
mod request;
use clap::{App, Arg, ArgGroup};
use crate::client::Client;
fn main() {
let matches = App::new("rural")
.version(env!("CARGO_PKG_VERSION"))
.author("https://github.com/saghm/rural")
.about("Command-line HTTP client... | true |
6f38f6ba3a3b85e3086342d31db118d588fe4fcd | Rust | Sinono3/simple-roguelike | /src/creature/combatant.rs | UTF-8 | 2,140 | 3.03125 | 3 | [
"MIT"
] | permissive | use specs::storage::GenericReadStorage;
use serde::{Serialize, Deserialize};
use specs::prelude::*;
use specs::error::NoError;
use specs::saveload::{Marker, ConvertSaveload};
use crate::unanimate::Wieldable;
#[derive(Component, Debug, Clone)]
#[storage(DenseVecStorage)]
pub struct Combatant {
pub strength: i32,
pub... | true |
e640fc5eff1f65c52416ca5ca49bd15e9a648d11 | Rust | jfoote/compute-rust-auth | /src/pkce.rs | UTF-8 | 1,035 | 2.96875 | 3 | [
"MIT"
] | permissive | use hmac_sha256::Hash;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use std::iter;
pub fn rand_chars(length: usize) -> String {
let mut rng = thread_rng();
iter::repeat(())
.map(|()| rng.sample(Alphanumeric))
.map(char::from)
.take(length)
.collect()
}
pu... | true |
64784a7a41246819ca2e37e98815341b91552ae5 | Rust | delaneyj/minigame-rust | /src/tile/layercomponent.rs | UTF-8 | 1,705 | 2.921875 | 3 | [
"MIT"
] | permissive | extern crate cgmath;
use color::Color;
use component::{Component};
use rectangle::Rectangle;
use texture::Texture;
use spritebatch::SpriteBatch;
use subtexture::Subtexture;
use entity::Entity;
use self::cgmath::Vector2;
use std::collections::HashMap;
use std::rc::Rc;
use std::option::Option;
use log::Log;
pub struct ... | true |
4b2758461d92213817de182c764ba428959a6e9e | Rust | sonygod/rust-project-euler | /euler57/src/main.rs | UTF-8 | 422 | 3.09375 | 3 | [] | no_license | extern crate num_bigint;
use num_bigint::BigUint;
fn main() {
let mut count = 0;
let mut a = BigUint::from(3 as u64);
let mut b = BigUint::from(2 as u64);
for _i in 2..=1000 {
let c = &a + &b;
a = &c + &b;
b = c;
println!("{} {}", a, b);
if a.to_string().len(... | true |
9c8c29d86b83763abdfd4df5ac0e1d4458748600 | Rust | sblundy/dedup-cli | /tests/integration_test.rs | UTF-8 | 1,945 | 2.625 | 3 | [
"MIT"
] | permissive | extern crate assert_fs;
extern crate predicates;
use assert_fs::prelude::*;
use assert_fs::NamedTempFile;
use predicates::prelude::*;
use std::io;
use dedup_cli::dedup_with_params;
#[test]
fn deduplicates_file_with_no_duplicates() {
let file = data::all_duplicates_file();
let input = file.path().to_str();
... | true |
912369173b035b98de0f030bd7038725bbaf8f54 | Rust | watashi/AlgoSolution | /codeforces/ac/16/1616/F.gauss.rs | UTF-8 | 6,675 | 2.96875 | 3 | [] | no_license | use std::*;
type MIntImpl = u8;
#[derive(Clone, Copy, Debug, Default)]
pub struct MIntT<const M: MIntImpl>(MIntImpl);
impl<const M: MIntImpl> From<MIntImpl> for MIntT<M> {
fn from(x: MIntImpl) -> Self {
Self(x % M)
}
}
impl<const M: MIntImpl> ops::Add for MIntT<M> {
type Output = Self;
fn ad... | true |
a3433617d97d6b15b47132104077b7250cb99e5c | Rust | goffrie/tokio | /tokio/src/runtime/tests/queue.rs | UTF-8 | 951 | 2.515625 | 3 | [
"MIT"
] | permissive | use crate::runtime::queue;
use crate::runtime::task::{self, Schedule, Task};
#[test]
fn steal_batch() {
let (steal1, mut local1) = queue::local();
let (_, mut local2) = queue::local();
let inject = queue::Inject::new();
for _ in 0..4 {
let (task, _) = task::joinable::<_, Runtime>(async {});
... | true |
ed77c32b4ea52280b164eaa09a6841d897b671b9 | Rust | hcyrs/cbuffer | /src/lib.rs | UTF-8 | 1,301 | 2.984375 | 3 | [
"MIT"
] | permissive | extern crate libc;
mod cbuffer_raw;
pub use cbuffer_raw::{channel, BufferSize, Sender, Receiver};
#[cfg(test)]
mod tests {
use chrono::Local;
#[test]
fn test_channel() {
use std::time::Duration;
use super::{channel, BufferSize};
use std::thread;
let (mut sender, mut rece... | true |
1541a67e6474ade51cb8d48615bd4266530ea9a5 | Rust | icanwalkonwater/adventofcode2019 | /day09/src/machine_state.rs | UTF-8 | 1,538 | 3.296875 | 3 | [] | no_license | use std::collections::VecDeque;
#[derive(Debug)]
pub struct MachineState {
halted: bool,
ip: usize,
bp: usize,
input: VecDeque<i64>,
output: VecDeque<i64>,
}
impl Default for MachineState {
fn default() -> Self {
MachineState::new()
}
}
impl MachineState {
pub fn new() -> Self... | true |
5e35aef855f017656ff68d452824a266b0cd71c6 | Rust | Ginkoe/CrabCrabGo | /src/ddg.rs | UTF-8 | 1,642 | 2.59375 | 3 | [] | no_license | use select::document::Document;
use urlparse::urlparse;
use urlparse::GetQuery;
use select::predicate::Class;
use crate::skeleton::ResultDDG;
pub fn scrap(target: &str) -> Result<Document, Box<std::error::Error>> {
let url = format!("https://duckduckgo.com/html/?q={}", target);
let resp = reqwest::get(&url)... | true |
eb1eae1bea38b18f7e297f04b32cd8e0c8ac3e79 | Rust | bexars/dtn-rust | /src/routing.rs | UTF-8 | 4,704 | 2.625 | 3 | [] | no_license | use crate::cla::cla_handle::HandleId;
use tokio::sync::mpsc::*;
use tokio::sync::RwLock;
use std::fmt;
use std::sync::Arc;
pub use self::route_table::RouteTableEntry as RouteTableEntry;
use arc_swap;
use arc_swap::ArcSwap;
use lazy_static::*;
lazy_static! {
pub static ref ROUTING_TABLE: ArcSwap<RouteTableEntry> = {
... | true |
e5bebe27bd2fc2294615675b890709872ed21592 | Rust | fizyk20/universal-chat | /src/sources/mod.rs | UTF-8 | 1,904 | 2.84375 | 3 | [] | no_license | use crate::core::{Channel, EventSourceBuilder, MessageContent};
use std::collections::HashMap;
#[cfg(feature = "discord")]
pub mod discord_source;
mod error;
#[cfg(feature = "irc")]
pub mod irc_source;
#[cfg(feature = "slack")]
pub mod slack_source;
pub mod stdin;
#[cfg(feature = "discord")]
pub use self::discord_sou... | true |
b4b327299b8dbee0c8d8bf85d33acf305eaf8f1f | Rust | joshwd36/S-Code | /src/main.rs | UTF-8 | 2,388 | 3 | 3 | [] | no_license | use itertools::Itertools;
use std::io;
fn main() {
let mut modules: Vec<(f32, i32, bool)> = Vec::new();
loop {
println!("Enter module grade, credits, whether can be s-coded (true/false). Leave blank to complete");
let mut buffer = String::new();
io::stdin().read_line(&mut buffer).unwrap... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.