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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b1f7483576fd8f79954f52347ba0a3f0f29f41a2 | Rust | xpepermint/httlib-rs | /protos/src/encoder/mod.rs | UTF-8 | 25,142 | 3.546875 | 4 | [
"MIT"
] | permissive | //! Provides an implementation of the `proto3` encoder.
//!
//! The encoder performs the task of transforming data fields into shrunken
//! binary format. This sequence of bytes is much smaller than the original
//! message which allows for much faster data transmission over the wire.
//!
//! Property names are repre... | true |
09b9fecc801a0622ef492ad30be62f27a81434d0 | Rust | webbestmaster/rust-lesson | /paper-book/p108-link/src/main.rs | UTF-8 | 506 | 3.671875 | 4 | [] | no_license | static mut STASH: &i32 = &1;
fn main() {
println!("Hello, world!");
let list = vec![6, 5, 4, 1, 2, 3];
let small = smallest(&list);
println!("small {}", small);
mut_no_mut();
}
// the same
// fn smallest<'a>(v: &'a [i32]) -> &'a i32 {
fn smallest(v: &[i32]) -> &i32 {
let mut s = &v[0];
f... | true |
8568575260192df1efec6a576215bd4ec0afaeca | Rust | wogsland/hashcode2019rust | /src/main.rs | UTF-8 | 939 | 3.21875 | 3 | [] | no_license | mod problem;
/// The main function takes 2 arguments from the command line: input & output file names.
fn main() {
let args = std::env::args().collect::<Vec<_>>();
let input = std::fs::read_to_string(&args[1]).unwrap();
let (score, output) = problem::solution(&input, 1.0);
eprintln!("Found solution w... | true |
7462af308caf718959f807e5800db7adebe7b717 | Rust | maxverbeek/Blockchain-based-E-voting | /myDigitalWalletWebApp/src/app/identity-core/src/crypto/key/reference.rs | UTF-8 | 610 | 2.8125 | 3 | [] | no_license | // Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use crate::crypto::KeyType;
/// A borrowed reference to a cryptographic key.
#[derive(Clone, Copy, Debug)]
pub struct KeyRef<'key> {
kty: KeyType,
key: &'key [u8],
}
impl<'key> KeyRef<'key> {
/// Creates a new [`KeyRef`] object.
pub ... | true |
9e2a4b894a4fa10d88a6e09ceb452fe17aa69b9a | Rust | nicofff/topsort | /src/topsort/decimal.rs | UTF-8 | 940 | 3.546875 | 4 | [] | no_license | use std::cmp::Ordering;
use std::str::FromStr;
use std::num::ParseIntError;
#[derive(Debug,Clone,Copy,Hash,PartialEq)]
pub struct Decimal {
whole: isize,
fractional: usize
}
impl Ord for Decimal {
fn cmp(&self, &other: &Self) -> Ordering {
let whole_comparison = self.whole.cmp(&other.whole);
if whole_co... | true |
caa48b62fb9b6aaa54e79f0de014e311e7012e2d | Rust | jrpelkonen/proxy-testing | /servers/rust/src/main.rs | UTF-8 | 1,460 | 2.671875 | 3 | [
"MIT"
] | permissive | use hyper::client::HttpConnector;
use hyper::service::{make_service_fn, service_fn};
use hyper::Error;
use hyper::{Body, Client, Request, Response, Server};
use std::convert::Infallible;
use std::net::SocketAddr;
use std::sync::Arc;
async fn proxy(
client: Client<HttpConnector, Body>,
host: &str,
scheme: &... | true |
2576a69686ececf0eabb3a8883b79199444fb500 | Rust | jesseduffield/delta | /src/cli.rs | UTF-8 | 10,097 | 2.78125 | 3 | [
"MIT"
] | permissive | use std::process;
use std::str::FromStr;
use std::string::ToString;
use console::Term;
use structopt::StructOpt;
use crate::bat::assets::HighlightingAssets;
use crate::bat::output::PagingMode;
use crate::config;
use crate::style;
#[derive(StructOpt, Clone, Debug)]
#[structopt(
name = "delta",
about = "A synt... | true |
a00c13b9ca7e7ed844d632f4509d5e115ef37b03 | Rust | sfackler/rust-time2 | /src/duration.rs | UTF-8 | 6,671 | 3.578125 | 4 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::time::Duration;
const NANOS_PER_SEC: u64 = 1_000_000_000;
const MILLIS_PER_SEC: u64 = 1_000;
const NANOS_PER_MILLI: u64 = NANOS_PER_SEC / MILLIS_PER_SEC;
/// Extensions to the `Duration` type.
pub trait DurationExt: Sized {
/// Returns the number of whole milliseconds contained in this `Duration`.
//... | true |
26e1adf9f3deddd518a7373afcefef941e622d98 | Rust | masonium/aoc2017 | /src/day08.rs | UTF-8 | 1,483 | 2.90625 | 3 | [] | no_license | use prelude::*;
fn test(a: i32, cmp: &str, b: i32) -> bool {
match cmp {
"==" => a == b,
"<" => a < b,
">" => a > b,
"<=" => a <= b,
">=" => a >= b,
"!=" => a != b,
_ => panic!("Invalid comparator: {}", cmp)
}
}
fn offset(op: &str, val: i32) -> i32 {
... | true |
c202a6c7828b663e8498812d0aeb77e51fd8f70d | Rust | ngi-nix/nixos-search | /flake-repos/src/main.rs | UTF-8 | 5,448 | 2.671875 | 3 | [] | no_license | use reqwest::{
header::{HeaderMap, AUTHORIZATION, LINK},
Url,
};
use serde::{Deserialize, Serialize};
use std::{
fs::{self, File},
io::Write,
path::PathBuf,
};
use structopt::StructOpt;
use toml;
#[derive(StructOpt)]
#[structopt(
name = "flake-repos",
about = "Given an input toml, create an... | true |
10daa140ce6197cb97fa428062d38237fdad7ad5 | Rust | peap/git-global | /tests/utils.rs | UTF-8 | 1,446 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::path::PathBuf;
use git_global::{Config, Repo};
/// Initialize an empty git repo in a temporary directory, then run a closure
/// that takes that Repo instance.
#[allow(dead_code)]
pub fn with_temp_repo<T>(test: T) -> ()
where
T: FnOnce(Repo) -> (),
{
let tempdir = tempfile::tempdir().unwrap();
le... | true |
fc258df836eb39171d1732376da310ea4fc9b460 | Rust | akitsu-sanae/verifront | /src/program/ml.rs | UTF-8 | 509 | 2.65625 | 3 | [
"BSL-1.0"
] | permissive | // tiny ML-like program
use super::{domain::*, ident::Ident};
#[derive(Debug)]
pub enum Expr<D: Domain> {
Const(D::ConstSymbol), // constatn values (e.g. true, 42)
Op(D::OperatorSymbol, Vec<Expr<D>>), // primitive operation (e.g. and, sub, mult and div)
If(Box<Expr<D>>, Box<Expr<D>>, Box<Expr... | true |
18c51614f3649d36010ab7142249c234f1b03190 | Rust | chom-parser/chom | /src/gen/parser/lr0.rs | UTF-8 | 14,004 | 2.546875 | 3 | [] | no_license | use super::super::{id, Context, Expr, Id, Label, Pattern};
use crate::{
mono,
parsing::table::{self, lr0::State, Rule},
};
use chom_ir::{
expr::{Error, MatchCase, SpanExpr, StackExpr, StreamExpr},
Constant,
};
use std::collections::HashSet;
/// ## Pseudo code
///
/// Operation prefixed by `#` are statically evalua... | true |
a6c6ee9d91407db73ce98bb593a2b74f72cbbe2a | Rust | hecrj/ggez | /src/tests/mesh.rs | UTF-8 | 2,286 | 2.921875 | 3 | [
"MIT"
] | permissive | use crate::tests;
use crate::*;
const TRIANGLE_VERTS: &[graphics::Vertex] = &[
graphics::Vertex {
pos: [0.0, 0.0],
uv: [0.0, 0.0],
color: [1.0, 1.0, 1.0, 1.0],
},
graphics::Vertex {
pos: [0.0, 0.0],
uv: [0.0, 0.0],
color: [1.0, 1.0, 1.0, 1.0],
},
grap... | true |
50f6575e692eabd3aaac46f63f218995483c503e | Rust | panicbit/advent_of_code_16 | /day13_2/src/main.rs | UTF-8 | 2,773 | 3 | 3 | [] | no_license | use std::collections::{HashMap, HashSet};
const INPUT: isize = 1364;
fn main() {
let start = (1,1);
let mut n = 0;
let max_steps = 50;
for x in 0..max_steps + 2 {
for y in 0..max_steps + 2 {
let is_ok = a_star(start, (x,y))
.map(|s| s.len() as isize - 1 <= max_steps... | true |
06b120f00f142edf8fc23641436524f40aa14771 | Rust | akeboshi/rust_study | /src/ch03_01.rs | UTF-8 | 354 | 3.109375 | 3 | [] | no_license | fn mutable_var() -> i32 {
let mut x = 5;
x = 20;
return x;
}
const MAX_POINTS: u32 = 100_000;
#[test]
fn mutable_test() {
assert_eq!(mutable_var(), 20);
}
#[test]
fn immutable_test() {
let x = 3;
assert_eq!(x, 3);
let x = "foo";
assert_eq!(x, "foo");
}
#[test]
fn const_test() {
a... | true |
1e835420576878a00f33c486e06e0ab952866e06 | Rust | richma-ms/iotedge | /mqtt/mqtt-broker/tests/integration.rs | UTF-8 | 8,155 | 2.53125 | 3 | [
"MIT"
] | permissive | ///! This module contains tests that verify non-MQTT related functionality
///! of the broker (like config, storage, cleanup, etc...).
///!
///! For tests related to MQTT protocol please use `compliance.rs`.
use std::{any::Any, convert::Infallible, time::Duration};
use chrono::Utc;
use mqtt3::{proto::ClientId, Connect... | true |
9ce697b3b6e358825e864a06a24cf5f89ef6a9cc | Rust | vhiribarren/json-parser-rust | /src/lexer.rs | UTF-8 | 18,356 | 2.96875 | 3 | [
"MIT"
] | permissive | /*
Copyright (c) 2020 Vincent Hiribarren
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribu... | true |
b92bc4b7cb08926f75445d51766a5e92768fe1fe | Rust | markafarrell/arp-cache | /src/lib.rs | UTF-8 | 8,160 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::net::Ipv4Addr;
use std::net::IpAddr;
use std::{thread, time};
use pcap;
use pnet::datalink::{
self,
MacAddr
};
use pnet::packet::{
MutablePacket,
Packet
};
use pnet::packet::ethernet::{
EtherTypes,
EthernetPacket,
MutableEthernetPacket
};
use pnet::p... | true |
24efa7bfec117f8b4e78262ad5989271f5385ca6 | Rust | agerasev/hypertrace | /objects/src/mapped.rs | UTF-8 | 510 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::marker::PhantomData;
use type_macros::*;
use types::{prelude::*, Map};
#[derive(Clone, EntityId, Entity, SizedEntity, EntitySource)]
pub struct Mapped<G: Geometry, T: Entity, M: Map<G::Pos, G::Dir>> {
geometry: PhantomData<G>,
pub map: M,
#[getter]
pub inner: T,
}
impl<G: Geometry, T: Entity,... | true |
4d4a7699a6cf1130197e4d620c061627c8ed2705 | Rust | fbksd/fbksd-server | /fbksd-ctl/src/main.rs | UTF-8 | 3,636 | 2.515625 | 3 | [] | no_license | //! fbksd-ctl binary.
//!
//! This is a command line utility that performs administrative tasks in the server.
use fbksd_core::docker;
use fbksd_core::paths;
use fbksd_core::registry as reg;
use fbksd_core::utils::CD;
use fbksd_core::utils::*;
use fbksd_core::{try_flock};
use fbksd_core::workspace as wp;
use wp::Works... | true |
225d5c975bec61bdfcbfe544a8054d0d59b87efc | Rust | hayatoito/icfp2021 | /src/api.rs | UTF-8 | 3,303 | 3.015625 | 3 | [] | no_license | use crate::prelude::*;
use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
fn api_token() -> Result<String> {
Ok(read_from_task_dir("api-token")?.trim().to_string())
}
fn get(path: &str) -> Result<String> {
let server_url = "https://poses.live/";
let auth_header = format!("Bearer {}", api_token(... | true |
14047cedf7e8a7c979fdef9a482a09b27899b1ec | Rust | kazuki/PenguinJudge | /agent/src/config.rs | UTF-8 | 1,248 | 2.734375 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::BufReader;
use std::path::Path;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct CompilationConfig {
#[serde(default)]
pub path: String,
#[serde(default)]
pub ext: String,
#[serde(default)]
pub output: String,
pub cmd:... | true |
18b0b38ad6c856248967be42f85d321454b27207 | Rust | Frezc/leetcode-solutions | /src/n0062_unique_paths.rs | UTF-8 | 2,209 | 3.6875 | 4 | [] | no_license | /**
* [62] Unique Paths
*
* A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
*
* The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
*
* How ma... | true |
0da02d8c723ff2f73f3912ab81bb993b28fcba3c | Rust | AratorRL/advent-of-code | /crates/day14/src/main.rs | UTF-8 | 5,352 | 3.296875 | 3 | [] | no_license | use anyhow::Result;
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::time::Instant;
#[derive(Debug, Clone)]
enum MaskBit {
Zero,
One,
Nothing,
}
#[derive(Debug, Clone)]
struct Mask {
bits: Vec<MaskBit>,
}
impl Mask {
fn new() -> Self {
... | true |
1a3c9a61c2b71f216bd2ff43a579f0023ac2875a | Rust | Osama530/simple_iot_api | /src/modules/route_lights.rs | UTF-8 | 1,442 | 2.734375 | 3 | [] | no_license | use rocket_contrib::json::Json;
use rocket::response::Redirect;
use crate::modules::lights::*;
//route to light setting to default colour mode
#[get("/lights")]
pub fn light_default()-> Json<Light> {
Json(
Light {
name: "balcony".to_string(),
switch: SimpleSwitch::create("lamp swi... | true |
44fea540a3e68228a128675e7d1c8e825863b6b5 | Rust | ccqpein/Arithmetic-Exercises | /Decode-XORed-Array/DxorA.rs | UTF-8 | 385 | 3.34375 | 3 | [
"Apache-2.0"
] | permissive | pub fn decode(encoded: Vec<i32>, mut first: i32) -> Vec<i32> {
let mut result = Vec::with_capacity(encoded.len() + 1);
result.push(first);
for i in encoded {
first = i ^ first;
result.push(first);
}
result
}
fn main() {
assert_eq!(decode(vec![1, 2, 3], 1), vec![1, 0, 2, 1]);
... | true |
3f3e4f23048f616893169a5977ae1956e67f00a8 | Rust | AgustinCB/rustedpond | /src/main.rs | UTF-8 | 2,279 | 2.578125 | 3 | [
"MIT"
] | permissive | extern crate rustedpond;
use rustedpond::*;
use std::time::{SystemTime, UNIX_EPOCH};
#[inline]
fn get_timestamp() -> usize {
let start = SystemTime::now();
start.duration_since(UNIX_EPOCH)
.expect("Time went backwards")
.subsec_nanos() as usize
}
#[inline]
fn mutate_cell(pond: &mut CellPond,
... | true |
10668ac07d58f5af0fc4101ee0aed42f8fb844d3 | Rust | dtb11288/rxrust | /src/extensions/skip.rs | UTF-8 | 2,106 | 3.28125 | 3 | [
"MIT"
] | permissive | use crate::observable::Observable;
use crate::observer::Observer;
use crate::{Subscription, BaseObserver};
use std::sync::{Arc, Mutex};
pub struct SkipObservable<O> {
original: O,
count: Arc<Mutex<u64>>,
}
pub trait SkipExt<'a>: Observable<'a> + Sized {
fn skip(self, count: u64) -> SkipObservable<Self> {
... | true |
f6b6c25c21cd21801a1d2d053a419079f100fdab | Rust | virtualritz/bevy-website | /generate-assets/src/bin/validate.rs | UTF-8 | 2,375 | 2.984375 | 3 | [
"MIT"
] | permissive | use regex::Regex;
use generate_assets::*;
fn main() -> Result<(), ()> {
let asset_dir = std::env::args().nth(1).unwrap();
if let Ok(asset_root_section) = parse_assets(&asset_dir) {
if asset_root_section.validate() {
Ok(())
} else {
Err(())
}
} else {
... | true |
1c470cde7153ef22b22bb808d7e2604ecb91c80e | Rust | IThawk/rust-project | /rust-master/src/test/run-pass/issues/issue-44333.rs | UTF-8 | 425 | 2.953125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
type Func = fn(usize, usize) -> usize;
fn foo(a: usize, b: usize) -> usize { a + b }
fn bar(a: usize, b: usize) -> usize { a * b }
fn test(x: usize) -> Func {
if x % 2 == 0 { foo }
else { bar }
}
const FOO: Func = foo;
const BAR: Func = bar;
fn main() {
match test(std::env::consts::ARCH.len()... | true |
f8fa96fa798f8e5dec9a310c2cec6de11741dfbb | Rust | Thewessen/hello-world | /Rust/control_flow/src/main.rs | UTF-8 | 1,315 | 3.5625 | 4 | [
"MIT"
] | permissive | use control_flow::fibbonaci;
#[allow(unused_variables)]
fn main() {
let b = if_else(10);
keep_looping();
return_from_loop();
while_loop();
lift_off();
combined_lift_off();
fibbonaci();
}
fn if_else(x: i32) -> bool {
// if-else is an expression!
let boolean = if x < 5 {
prin... | true |
af3d3ca9ac22e8673238f7bc88d187cfd0c256bc | Rust | utam0k/deno_lint | /src/rules/no_case_declarations.rs | UTF-8 | 3,854 | 2.5625 | 3 | [
"MIT"
] | permissive | // Copyright 2020 the Deno authors. All rights reserved. MIT license.
use super::Context;
use super::LintRule;
use swc_ecma_ast::Decl;
use swc_ecma_ast::Stmt;
use swc_ecma_ast::SwitchCase;
use swc_ecma_ast::VarDeclKind;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
pub struct NoCaseDeclarations;
impl LintRule ... | true |
e2a5304ad51e574b93e9ab82a401d649a66aa3f7 | Rust | bboozzoo/r64 | /src/cpu.rs | UTF-8 | 21,193 | 2.515625 | 3 | [] | no_license | // The MIT License (MIT)
//
// Copyright (c) 2020 Maciek Borzecki <maciek.borzecki@gmail.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limi... | true |
c0e00d76df5a566ed641cf20b5af7b21c90631d8 | Rust | jrmiller82/shipyard | /src/world/mod.rs | UTF-8 | 71,222 | 2.78125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | mod scheduler;
pub use scheduler::WorkloadBuilder;
use crate::atomic_refcell::AtomicRefCell;
#[cfg(feature = "serde1")]
use crate::atomic_refcell::RefMut;
use crate::borrow::Borrow;
use crate::entity_builder::EntityBuilder;
use crate::error;
#[cfg(feature = "serde1")]
use crate::serde_setup::{ExistingEntities, Global... | true |
0b4e51715472cca5e87cd750ef952109200ef7a1 | Rust | quilt/lighthouse | /eth2/types/src/test_utils/builders/testing_attestation_builder.rs | UTF-8 | 2,846 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use crate::test_utils::TestingAttestationDataBuilder;
use crate::*;
use tree_hash::TreeHash;
/// Builds an attestation to be used for testing purposes.
///
/// This struct should **never be used for production purposes.**
pub struct TestingAttestationBuilder {
committee: Vec<usize>,
attestation: Attestation,
}... | true |
af57e23f87bf560c55bf80c1507e9bf5cb62c6b1 | Rust | bash/toby | /src/cli/toby.rs | UTF-8 | 2,327 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::config::get_config;
use crate::fs::write_telegram_chat_id;
use crate::telegram::{Api, ParseMode, SendMessageParams};
use crate::unwrap_err;
use nanoid;
use std::thread;
use std::time::Duration;
pub fn gen_secret() {
println!("{}", nanoid::simple());
}
pub fn telegram_setup() {
let token = nanoid::g... | true |
0dd2576feedcc63c4a4a5bb979c368bf9e5a522f | Rust | janigbg/advent_of_code_2019 | /src/bin/2b.rs | UTF-8 | 1,340 | 2.84375 | 3 | [
"Unlicense"
] | permissive | extern crate advent_of_code_2019;
use advent_of_code_2019::{intcode, parser};
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
parser::print_args(&args);
let program = program(&args);
let expected = 19690720;
let mut found: Option<(i64, i64)> = None;
for i in 0..100... | true |
0b07211dfaedbcc9e47f57c32e0109afa43641e5 | Rust | skrap/tmq | /examples/response.rs | UTF-8 | 1,184 | 2.640625 | 3 | [] | no_license | extern crate futures;
extern crate pretty_env_logger;
extern crate tmq;
extern crate tokio;
#[macro_use]
extern crate log;
extern crate failure;
use failure::Error;
use futures::future::ok;
use futures::future::FutureResult;
use futures::Future;
use tmq::*;
use std::env;
fn main() {
if env::var("RUST_LOG").is_e... | true |
2fb6333ded17a515ca9f2da9fabb959ffabf05b8 | Rust | badboy/iso8601 | /tests/lib.rs | UTF-8 | 27,112 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use iso8601::*;
#[test]
fn test_date() {
assert_eq!(
Ok(Date::YMD {
year: 2015,
month: 6,
day: 26,
}),
date("2015-06-26")
);
assert_eq!(
Ok(Date::YMD {
year: -333,
month: 7,
day: 11,
}),
... | true |
64e63f1ab2d3f4d016e15dc4a26e4d076acf14f2 | Rust | clarkenciel/rust-automata | /src/rule90.rs | UTF-8 | 848 | 3.03125 | 3 | [] | no_license | use cell::Cell;
use rule::Rule;
pub struct Rule90;
type NeighborData = (bool, bool);
impl<C> Rule<NeighborData, C> for Rule90
where
C: Cell,
{
fn evaluate(&self, neighbors: &NeighborData, cell: &C) -> C {
match (*neighbors, cell.is_alive()) {
// 010
((false, false), true) => C... | true |
c830ee5b81e9b81284f053794e78484942bf356c | Rust | extrawurst/azure-sdk-for-rust | /sdk/storage/examples/copy_blob_from_url.rs | UTF-8 | 1,585 | 2.53125 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT"
] | permissive | use azure_core::prelude::*;
use azure_storage::blob::Blob;
use azure_storage::core::prelude::*;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// First we retrieve the account name and master key from environment variables.
let account =
std::env::var("STORAGE_ACC... | true |
d6cac7f37cc026f9dd490d0193f1537f785d2ce0 | Rust | shipwreck-project/boardconnect-server | /src/services/test.rs | UTF-8 | 964 | 2.640625 | 3 | [] | no_license | use crate::models::*;
use crate::models;
use crate::services::Pool;
use diesel::prelude::*;
use diesel::MysqlConnection;
pub struct Service {
pool: Pool,
}
impl Service {
pub fn new(self, pool: Pool) -> Service {
Service { pool: pool }
}
pub fn connection_test_insert(self) -> super::DieselResult<usize> ... | true |
4b22a785541c596315fa53ef01421fcbc26a0de1 | Rust | shino16/cp_rust | /src/ds/list.rs | UTF-8 | 1,458 | 3.265625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::iter::FromIterator;
use std::rc::Rc;
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
pub struct List<T>(Option<Rc<(T, List<T>)>>);
impl<T> Default for List<T> {
fn default() -> Self {
Self::new()
}
}
impl<T> List<T> {
pub fn new() -> Self {
Self(None)
}
pub fn pus... | true |
17fdfcbb803e02ac89e17d97f820cfd47c406387 | Rust | vni/simple-games | /rust-sdl-snake/src/config.rs | UTF-8 | 705 | 3.515625 | 4 | [] | no_license | pub struct Config {
pub width: u32,
pub height: u32,
pub pixel_size: u32,
}
impl Config {
pub fn from_args() -> Self {
/*
let args = std::env::args().collect();
for arg in args.iter() {
}
*/
// TODO: Default values. Let them be readed from command line.... | true |
0a83e0c03caa4fae45712ee6479e75633ccdb7ee | Rust | Douile/notify-server-rs | /src/main.rs | UTF-8 | 3,198 | 3.0625 | 3 | [
"MIT"
] | permissive | // vim: ts=4 :
use std::net::{IpAddr, SocketAddr, UdpSocket};
use std::thread;
use std::process::Command;
use std::str::FromStr;
use notify_rust::Notification;
use serde::Deserialize;
use structopt::StructOpt;
#[derive(StructOpt)]
struct Cli {
#[structopt(default_value = "1337", long, short="p", help = "Set port... | true |
6645b328e2d957fe2403b465973e12f7544ab127 | Rust | uJhin/upbit-client | /swg_generated/rust/src/models/new_order.rs | UTF-8 | 8,121 | 2.546875 | 3 | [
"MIT"
] | permissive | /*
* Upbit Open API
*
* ## REST API for Upbit Exchange - Base URL: [https://api.upbit.com] - Official Upbit API Documents: [https://docs.upbit.com] - Official Support email: [open-api@upbit.com]
*
* OpenAPI spec version: 1.0.0
* Contact: ujhin942@gmail.com
* Generated by: https://github.com/swagger-api/swagger... | true |
bc7ec7fb4579979c9d9782948ae91cb483894585 | Rust | stepancheg/rust-http2 | /httpbis/src/solicit/header/value.rs | UTF-8 | 3,693 | 2.984375 | 3 | [
"MIT"
] | permissive | use crate::ascii::Ascii;
use crate::solicit::header::HeaderError;
use bytes::Bytes;
use std::fmt;
/// A convenience struct representing a header value.
#[derive(Eq, PartialEq, Hash, Clone)]
pub struct HeaderValue(Ascii);
impl HeaderValue {
/// Validate and create header value from bytes.
pub fn from_bytes(bs:... | true |
054ae2bab59a97021fc79ba12b419a29437debad | Rust | tmzint/roundabout | /src/message/bus.rs | UTF-8 | 22,267 | 2.796875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::message::buffer::{MessageBuffer, MessageHeader};
use crate::message::vec::MessageVec;
use crate::message::{MessageRegistry, PaddingMessage};
use crate::util::CacheLineAligned;
use crate::wait::WaitingStrategy;
use std::mem::ManuallyDrop;
use std::ops::Deref;
use std::sync::atomic::{AtomicUsize, Ordering};
us... | true |
e0f131c77cd6e12c2fcfb08aa2c225b93e7eb673 | Rust | rust-lang/rust | /tests/ui/type-alias-impl-trait/issue-90400-2.rs | UTF-8 | 703 | 2.609375 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // Regression test for #90400,
// taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836
#![feature(impl_trait_in_assoc_type)]
trait Bar {
fn bar(&self);
}
trait Baz {
fn baz(&self);
}
trait Foo {
type FooFn<B>: Baz;
fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B>;
}
stru... | true |
31bc55526d70f311e14abb15f78bec323c2df2fb | Rust | rhinterberger/advent | /2019/day15/src/main.rs | UTF-8 | 8,479 | 3.21875 | 3 | [] | no_license | use std::{fs, thread};
use std::sync::mpsc::{channel, Sender, Receiver};
use std::collections::{HashMap, HashSet, VecDeque};
use std::ops::{Add, Sub};
fn main()
{
let filecontents = fs::read_to_string("input.txt").unwrap();
let mut repairbot: Vec<i64> = filecontents.trim().split(",").map(|value| value.parse::... | true |
a81b3cd00673bf01607938222c32ffb0c5751ec5 | Rust | grantlemons/neo4rs | /lib/src/types/date_time.rs | UTF-8 | 5,949 | 3 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::errors::Error;
use crate::types::*;
use chrono::{DateTime, FixedOffset, NaiveDateTime, Offset, Timelike};
use neo4rs_macros::BoltStruct;
use std::convert::TryInto;
#[derive(Debug, PartialEq, Clone, BoltStruct)]
#[signature(0xB3, 0x46)]
pub struct BoltDateTime {
seconds: BoltInteger,
nanoseconds: Bol... | true |
a3d3c7f6c7065865b10fb525775958eaed60b4f0 | Rust | DrSloth/Rocket | /core/lib/src/local/mod.rs | UTF-8 | 7,707 | 4.09375 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | //! Structures for local dispatching of requests, primarily for testing.
//!
//! This module allows for simple request dispatching against a local,
//! non-networked instance of Rocket. The primary use of this module is to unit
//! and integration test Rocket applications by crafting requests, dispatching
//! them, and... | true |
2e4528ae8b1bc6d2a4c9d2c7165dd95c503ed0df | Rust | pie-flavor/lpc176x-5x | /src/syscon/pclksel1.rs | UTF-8 | 57,726 | 2.6875 | 3 | [
"WTFPL"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::PCLKSEL1 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... | true |
f57945368cd3aa999c35e81b7b29b761799e435b | Rust | akimash/abc | /76/c.rs | UTF-8 | 1,264 | 3.359375 | 3 | [] | no_license | use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
let stdin = stdin();
let stdin = stdin.lock();
let token: String = stdin
.bytes()
.map(|c| c.expect("failed to read char") as char)
.skip_while(|c| c.is_whitespace())
.take_while(|c| !c.is_whitespace())
... | true |
6410e2a42ee4713afbfcf3d88d1a491310f3b4b9 | Rust | ciusji/ferris | /src/example/functions/closures.rs | UTF-8 | 1,316 | 3.671875 | 4 | [
"Apache-2.0"
] | permissive | // Copyright 2021 Ferris Project Authors. License user Apache License.
// Closure
// Closures are functions that can capture the enclosing environment. For example, a closure that
// captures the x variable.
// |val| val + x
// The syntax and capabilities of closures make them very convenient for on the fly usage. Ca... | true |
445d9fe6ddbc75837e849ccaf79d46d44591df55 | Rust | gr-g/advent-of-code-2019 | /src/bin/14.rs | UTF-8 | 4,312 | 3.515625 | 4 | [
"Unlicense"
] | permissive | use std::collections::HashMap;
struct ReactionItem {
amount: i64,
item: String,
}
impl ReactionItem {
fn create_from(s: &str) -> ReactionItem {
let (amount, item) = s.split_once(' ').unwrap();
ReactionItem {
amount: amount.parse().unwrap(),
item: item.to_string(),
... | true |
8d44211ad36ff9de35006b6e15bd5b8f33a8f1c1 | Rust | valarauca/llvm_bind | /src/module.rs | UTF-8 | 3,741 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive |
use llvm_sys::*;
use llvm_sys::prelude::*;
use llvm_sys::core::*;
use llvm_sys::analysis::*;
use llvm_sys::bit_writer::*;
use std::ffi::{CString,CStr};
use std::os::raw::c_char;
use std::mem;
use super::Buffers;
use super::buffer::Buffer;
use super::target::get_local_triple;
const NULLPTR: &'static str = "
Module n... | true |
ca325a083ab88d2757e00601c24d7143155943a8 | Rust | silvia-odwyer/beginner-rust-examples | /Arithmetic/fuel_efficiency/fuel_efficiency.rs | UTF-8 | 648 | 3.859375 | 4 | [] | no_license | use std::io;
fn main() {
let mut mpg = String::new();
println!("Please enter a float value for the mpg.");
io::stdin().read_line(&mut mpg)
.expect("Failed to read line");
let mpg: f32 = match mpg.trim().parse() {
Ok(num) => num,
Err(_) => 0.0
};
// Only a f... | true |
cdff74dd701e90caefdd85c14cb9a5451f0cdf05 | Rust | jvff/async-protocol | /src/tests/common/to_upper_service.rs | UTF-8 | 396 | 2.53125 | 3 | [] | no_license | use futures::future::{FutureResult, IntoFuture};
use tokio_service::Service;
pub struct ToUpperService;
impl Service for ToUpperService {
type Request = String;
type Response = String;
type Error = ();
type Future = FutureResult<Self::Response, Self::Error>;
fn call(&self, request: Self::Request)... | true |
966e25841fd34a416f0966dc0f717cc057ce2ffb | Rust | jackpot51/puccinia | /alpha_vantage/src/crypto_daily.rs | UTF-8 | 646 | 3.046875 | 3 | [
"MIT"
] | permissive | use std::collections::BTreeMap;
#[derive(Debug, Deserialize)]
pub struct CryptoDailyPoint {
#[serde(rename = "1a. open (USD)")]
pub open: String,
#[serde(rename = "2a. high (USD)")]
pub high: String,
#[serde(rename = "3a. low (USD)")]
pub low: String,
#[serde(rename = "4a. close (USD)")]
... | true |
1706bc8c9f9bfaf90c4071e11710b3c49e38eb5c | Rust | apboobalan/minigrep | /src/grep.rs | UTF-8 | 1,757 | 3.28125 | 3 | [] | no_license | use crate::config::Config;
use crate::error::ExitOnError;
use std::{env, fs, io};
pub fn run() -> () {
let args = env::args().collect();
let config = Config::from(&args).else_exit_on_error();
grep_lines_from_file(&config);
}
fn grep_lines_from_file(config: &Config) -> () {
let file_contents = read_fil... | true |
f2e2b99a3d2953a68a1d072da6985f83103c59a3 | Rust | nuts-rice/rust_blockchain | /src/rust_chain/mod.rs | UTF-8 | 5,727 | 2.75 | 3 | [] | no_license | extern crate blake2;
use std::vec::Vec;
use std::collections::HashMap;
use std::convert::Into;
use std::time::SystemTime;
use blake2::{Blake2b, Digest};
use std::string::String;
use std::convert::From;
#[derive(Debug, Clone)]
pub struct Blockchain {
//Stores all the blocks which are in the blockchain
pub blo... | true |
8957a748cd8d169fcf09a52de31377a1e195a134 | Rust | forksbot/embedded-graphics | /simulator/examples/offscreen.rs | UTF-8 | 708 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use embedded_graphics::{
pixelcolor::BinaryColor, prelude::*, primitives::Rectangle, style::PrimitiveStyle,
};
use embedded_graphics_simulator::{SimulatorDisplay, WindowBuilder};
fn main() -> Result<(), core::convert::Infallible> {
let mut display: SimulatorDisplay<BinaryColor> = SimulatorDisplay::new(Size::ne... | true |
19119a4f4d4a1c94f07a7c35957ea2e988a2dc80 | Rust | deislabs/dwaft | /src/main.rs | UTF-8 | 212 | 2.5625 | 3 | [] | no_license | fn main() {
println!(
"Dwaft. Dwaft is wot bwings us togeder today.
Dwaft, that bwessed tool, that turtle wifin a turtle...
And wasm, tru wasm, will fowo you foweva...
So tweasure your wasm"
);
}
| true |
85124b68a8c02645f64cbaaea02c9f639dbc3636 | Rust | sman2013/file-tools | /src/subcommand/params.rs | UTF-8 | 2,003 | 3.015625 | 3 | [] | no_license | use structopt::StructOpt;
#[derive(Debug, Clone, StructOpt)]
pub enum CoreParams {
/// Replace file name by specify 'str'.
#[structopt(name = "replace")]
Replace(ReplaceCmd),
/// Insert string to file name.
#[structopt(name = "insert")]
Insert(InsertCmd),
/// Rename file name by specify rules.
#[structopt(name... | true |
f695e526c5686161b0c03a5a76280f31966a8e45 | Rust | sibaba8888/rustdx | /src/tcp/basic.rs | UTF-8 | 6,855 | 2.90625 | 3 | [
"MIT"
] | permissive | use super::{u16_from_le_bytes, Result, Tdx};
/// 心跳包。用于保持 Tcp 连接。
pub type Heartbeat = SecurityCount;
/// 对应 pytdx 的 hq.security_count / GetSecurityCountCmd
/// (深沪市证券数量,包括指数、股票和大量债券)、心跳包。
#[derive(Debug)]
pub struct SecurityCount {
send: Box<[u8]>,
/// 0 代表深市;1 代表沪市。
market: u16,
/// 响应的结果:证券数量
... | true |
16a3dfb5e274160af9e926557ec94140367435ea | Rust | watashi/AlgoSolution | /codeforces/ac/16/1611/B.rs | UTF-8 | 618 | 2.6875 | 3 | [] | no_license | use std::{cmp::*, *};
fn read_line() -> String {
let mut line = String::new();
io::stdin().read_line(&mut line).unwrap();
line
}
fn read_vec() -> Vec<usize> {
read_line()
.split_whitespace()
.filter_map(|i| i.parse().ok())
.collect()
}
fn main() {
let re = read_line().trim... | true |
59702f2a26e1eb1368d9d6f33d1c9edc4a10c804 | Rust | gpestana/valora | /src/render.rs | UTF-8 | 9,292 | 2.8125 | 3 | [
"MIT"
] | permissive | //! Canvas rendering.
use crate::{canvas::*, gpu::*, paint::*, uniforms::*, Options, Result, World};
use glium::{
glutin::event_loop::{ControlFlow, EventLoop},
texture::{texture2d_multisample::Texture2dMultisample, Dimensions, MipmapsOption},
Frame, GlObject, Program,
};
use glutin::platform::desktop::Even... | true |
0333749e3e0b4342657c94b77f67d70ee0aff681 | Rust | mashtizadeh/wasmtime | /crates/api/src/linker.rs | UTF-8 | 17,079 | 3.421875 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | use crate::{
Extern, ExternType, Func, FuncType, GlobalType, ImportType, Instance, IntoFunc, Module, Store,
};
use anyhow::{anyhow, bail, Result};
use std::collections::hash_map::{Entry, HashMap};
use std::rc::Rc;
/// Structure used to link wasm modules/instances together.
///
/// This structure is used to assist ... | true |
a3a6c34b0e1ed62ec5fae5b93387d4caed9c4432 | Rust | mapno/cses_solutions | /hotel_queries/src/main.rs | UTF-8 | 1,961 | 3.1875 | 3 | [] | no_license | use std::io::{BufRead, Write};
fn main() {
let stdout = std::io::stdout();
let mut stdout = std::io::BufWriter::new(stdout.lock());
let stdin = std::io::stdin();
let mut scanner = Scanner::new(stdin.lock());
let (n, m): (usize, usize) = (scanner.token(), scanner.token());
let mut k: usize = 1;... | true |
a906e816b818a62cd0e69ad3d48aab01ae812078 | Rust | anthhub/yew-train-ticket | /src/store/store.rs | UTF-8 | 2,347 | 3.25 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use chrono::prelude::*;
#[derive(Clone, Debug, PartialEq)]
pub struct StoreModel {
pub from: String,
pub to: String,
pub local_time: DateTime<Local>,
pub is_high_speed: bool,
pub date_selector_visible: bool,
pub city_selector_visible: bool,
pub is_selecting_from: bool,
}
pub enum Action {
... | true |
bebf042474b0cf582832692352a4276504606158 | Rust | TorsteinTenstad/town_sim | /src/location_history.rs | UTF-8 | 1,060 | 3.171875 | 3 | [] | no_license | use crate::vec2D::Vec2D;
pub struct LocationHistory {
timespan: usize,
index: usize,
locations: Vec<Vec2D<f64>>,
}
impl LocationHistory {
pub fn new(start_pos: Vec2D<f64>, timespan: usize) -> LocationHistory{
LocationHistory {
timespan,
index: 0,
locations: ... | true |
c2ccae9157eb66c725e980af5448cdbfee5ceecd | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/abc235/src/bin/c.rs | UTF-8 | 695 | 2.625 | 3 | [] | no_license | use std::collections::HashMap;
use proconio::input;
fn main() {
input! {
n: usize,
q: usize,
a: [usize; n],
xk: [(usize, usize); q],
};
let mut map = HashMap::new();
for (i, a_i) in a.iter().copied().enumerate() {
map.entry(a_i).or_insert(vec![]).push(i);
}... | true |
845a50d26b503f80c794621449576533d0418280 | Rust | baurine/leetcode | /euler/rust/src/euler_2.rs | UTF-8 | 879 | 3.4375 | 3 | [] | no_license | /*
400 万之内所有偶数的斐波那契数字之和。
*/
pub fn solution_1() -> u32 {
let mut fib_arr = vec![1, 2];
let mut sum = 2;
let mut i = 2;
loop {
let next_fib = fib_arr[i-1] + fib_arr[i-2];
if next_fib > 400_0000 {
break;
}
if next_fib % 2 == 0 {
sum += next_fib;
}
fib_arr.push(next_fib);
i... | true |
1bc8e07a762753414830d592efb64e8bd748d273 | Rust | matematikaadit/haus | /src/id.rs | UTF-8 | 1,765 | 3.40625 | 3 | [
"MIT"
] | permissive | use std::fmt;
use std::borrow::Cow;
use std::convert::AsRef;
use rocket::request::FromParam;
use rocket::http::RawStr;
use rand::{self, Rng};
/// Table to retrieve base 36 values from.
const BASE36: &[u8] = b"0123456789abcdefghijklmnopqrstuvwxyz";
/// A _probably_ unique paste ID.
pub struct Id<'a>(Cow<'a, str>);
i... | true |
993aff8b4eb3398f7e0d8b54b701482da42d38c0 | Rust | bellps/rust-course | /src/bin/a3a.rs | UTF-8 | 139 | 3.359375 | 3 | [] | no_license | fn main(){
let is_hungry = true;
if is_hungry {
println!("Wanna eat!!!!1")
} else {
println!("Wanna sleep zzzzzzzzzz")
}
} | true |
b84ec04db7e5973552389447ca77f686f7f7d201 | Rust | frankegoesdown/LeetCode-in-Go | /Algorithms/0432.all-oone-data-structure/all-oone-data-structure_test.go | UTF-8 | 860 | 2.671875 | 3 | [
"MIT"
] | permissive | package problem0432
import (
"strconv"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_AllOne(t *testing.T) {
ast := assert.New(t)
a := Constructor()
ast.Equal("", a.GetMaxKey())
ast.Equal("", a.GetMinKey())
a.Inc("6")
ast.Equal("6", a.GetMaxKey())
ast.Equal("6", a.GetMinKey())
a.Dec("6")
... | true |
3d945dab796b498077a07262cca19d5e64aa1750 | Rust | feather-rs/feather | /feather/worldgen/src/superflat.rs | UTF-8 | 2,885 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | use base::{anvil::level::SuperflatGeneratorOptions, Biome, BlockId, Chunk, ChunkPosition};
use crate::WorldGenerator;
pub struct SuperflatWorldGenerator {
pub options: SuperflatGeneratorOptions,
}
impl SuperflatWorldGenerator {
pub fn new(options: SuperflatGeneratorOptions) -> Self {
Self { options }... | true |
4d84bd52d7e20879736c215228c80fa12af74271 | Rust | ccqpein/Arithmetic-Exercises | /Truncate-Sentence/TS.rs | UTF-8 | 747 | 3.359375 | 3 | [
"Apache-2.0"
] | permissive | use std::iter::FromIterator;
pub fn truncate_sentence(s: String, mut k: i32) -> String {
let mut cc: Vec<char> = vec![];
for c in s.chars() {
if c == ' ' {
k -= 1;
}
if k == 0 {
break;
}
cc.push(c);
}
String::from_iter(cc)
}
fn main() {
... | true |
5b287fa67f5c909f1d708d399043a07159750f1b | Rust | CGUTA/palette | /palette/src/rgb.rs | UTF-8 | 3,468 | 3.03125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! RGB types, spaces and standards.
use crate::encoding::{self, Gamma, Linear, TransferFn};
use crate::white_point::WhitePoint;
use crate::{Component, FloatComponent, FromComponent, Yxy};
pub use self::packed::{channels, Packed, RgbChannels};
pub use self::rgb::{FromHexError, Rgb, Rgba};
mod packed;
mod rgb;
/// N... | true |
88d05013dbe93c00900139aa35cfd63e8a8107e5 | Rust | harikrishnanm/script | /src/collection/collection.rs | UTF-8 | 2,691 | 2.71875 | 3 | [] | no_license | use crate::collection::models::*;
use crate::constants;
use crate::rbac::models::*;
use crate::DBPool;
use log::*;
use sqlx::Error;
use uuid::Uuid;
impl NewCollection {
pub async fn save(
self: &Self,
site_name: String,
identity: Identity,
db_pool: &DBPool,
) -> Result<Collectio... | true |
ca4d6560dfbeceb8423b06ac854d122b7554f814 | Rust | rust-lang/rust | /tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs | UTF-8 | 505 | 3.046875 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // Tests that specializing trait impls must be at least as const as the default impl.
#![feature(const_trait_impl, effects)]
#![feature(min_specialization)]
#[const_trait]
trait Value {
fn value() -> u32;
}
impl<T> const Value for T {
default fn value() -> u32 {
0
}
}
struct FortyTwo;
impl Valu... | true |
36b323e5b86c631320f2fb173a0f575e8e76e56a | Rust | inickt/cs4500-wortham | /D/Other/src/main.rs | UTF-8 | 3,307 | 3.0625 | 3 | [] | no_license | use gio::prelude::*;
use gtk::prelude::*;
use gtk::DrawingArea;
use std::cmp::max;
const LEFT_CLICK: u32 = 1;
#[derive(Clone)]
struct Hexagon(pub [(f64, f64); 6]);
impl Hexagon {
fn new(size: f64) -> Hexagon {
let mut default_hexagon: [(f64, f64); 6] = [
(0.0, 1.0), (1.0, 2.0), (2.0, 2.0),... | true |
eaa23e814158a987d94ef89881ea18acf3b8649a | Rust | laopo001/hello_rust | /src/bin/main6.rs | UTF-8 | 253 | 3.03125 | 3 | [] | no_license | #[derive(Debug, Copy, Clone)]
struct A {
name: i32,
}
#[derive(Debug)]
struct B {
a: A,
}
fn run(mut a: Box<A>) {
a.name = 123;
dbg!(a.name);
}
fn main() {
let a = Box::new(A { name: 0 });
run(a.clone());
dbg!(a.name);
}
| true |
68366b0421bce82b67017d6d334fead45cdd7d4a | Rust | porky11/ncollide | /ncollide_geometry/shape/capsule.rs | UTF-8 | 1,714 | 3.21875 | 3 | [
"BSD-2-Clause"
] | permissive | //! Support mapping based Capsule shape.
use num::Signed;
use alga::general::Real;
use na::{self, Unit};
use shape::SupportMap;
use math::{Isometry, Point};
/// SupportMap description of a capsule shape with its principal axis aligned with the `y` axis.
#[derive(PartialEq, Debug, Clone)]
pub struct Capsule<N> {
... | true |
f169ecf3f3d258af0464fb5f296739e5fc2924b1 | Rust | toyseed/rust-module-test | /src/single_file.rs | UTF-8 | 878 | 3.375 | 3 | [] | no_license | pub mod single {
pub fn function() {
println!("hello single");
}
pub mod nested {
use crate::sibling;
pub fn function() {
// str 에 - 가 포함되어 있으면 println! 결과에 개행이 적용되지 않음.
println!("hello single - nested");
}
pub fn call_sibling() {
... | true |
ee400c6f94b2781e69e5c4107e7699edf784e921 | Rust | Takayamashi/HoloStats | /server/holostats-database/statistic.rs | UTF-8 | 5,298 | 2.703125 | 3 | [
"MIT"
] | permissive | use chrono::{serde::ts_milliseconds, DateTime, Utc};
use serde::Serialize;
use sqlx::Result;
use tracing::instrument;
use super::Database;
type UtcTime = DateTime<Utc>;
pub struct Statistic {
pub id: String,
pub time: UtcTime,
pub value: i32,
}
#[derive(serde::Serialize)]
pub struct Timestamp(#[serde(wi... | true |
e342853272c6a8edf6241ee5d42947c9742c66ec | Rust | nbari/dsn | /src/lib.rs | UTF-8 | 10,558 | 3.484375 | 3 | [
"BSD-3-Clause"
] | permissive | //!DSN (Data Source Name) parser
//!
//!DSN format:
//!```text
//!<driver>://<username>:<password>@<protocol>(<address>)/<database>?param1=value1&...¶mN=valueN
//!```
//!
//!A DSN in its fullest form:
//!
//!```text
//!driver://username:password@protocol(address)/dbname?param=value
//!```
//!
//!The address changes... | true |
b05aed9d5f55ab5ba0cf85b8c54a7336a63deed8 | Rust | Peternator7/cracker-barrel-rust | /src/main.rs | UTF-8 | 1,554 | 3.09375 | 3 | [
"MIT"
] | permissive | mod graph;
use graph::*;
const MOVES: [Point;6] = [Point(2,0), Point(-2,0), Point(0,2), Point(0,-2), Point(-2,-2), Point(2,2)];
fn main () {
let dim = 5;
println!("Hello World");
let mut g = Graph::triangle_from_size(dim);
let mut id = 1;
for i in 1..(dim as isize) {
for j in 0..i+1 {
... | true |
73b1a63c448373f53d8789bec7092f6f2790e8ce | Rust | phaylon/sym-engine | /tests/running.rs | UTF-8 | 7,782 | 2.875 | 3 | [
"MIT"
] | permissive |
use sym_engine::*;
use assert_matches::{assert_matches};
#[track_caller]
fn test_package(rules: &str) -> (System, Space, Id, Id) {
let mut system = System::new("test", &["A", "B"]).unwrap();
let mut loader = SystemLoader::new(vec![&mut system]);
loader.load_str(rules).expect("rules load successful");
... | true |
5e732160609528ec79e8478dad70e6b5abda8a58 | Rust | bumblepie/advent-of-code-2018 | /day-23/part-1/src/main.rs | UTF-8 | 2,522 | 2.84375 | 3 | [] | no_license | extern crate regex;
#[macro_use]
extern crate lazy_static;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::process;
use regex::Regex;
fn main() {
let args: Vec<String> = env::args().collect();
let filename = &args[1];
let file = File::open(filename).expect("Unab... | true |
861ba6f29775ed95a827d7c378be682b6c2a0f5e | Rust | mmoessmer/northstar | /examples/seccomp/src/main.rs | UTF-8 | 248 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | fn main() {
let version = std::env::var("VERSION").unwrap_or_else(|_| "unknown".into());
loop {
println!("Hello from the seccomp example version {}!", version);
std::thread::sleep(std::time::Duration::from_secs(5));
}
}
| true |
10b97817642e1ded42f393b8cf8dd8a0bc6be377 | Rust | JustAPerson/denuos | /src/kernel/arch/x86/frame_allocator.rs | UTF-8 | 4,887 | 3.546875 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Simple Page Frame Allocator
//!
//! A `Frame` contains the physical memory that may be mapped by a virtual
//! page. We are given a memory map from the `MultibootInfo`. This defines the
//! regions of memory that are safe for use. Currently we are only concerned
//! with a unique allocation of frames. Reuse is unsu... | true |
a73164a423ed53495c113cec8ce56985b7d87d8e | Rust | yeethawe/PokemonRust | /pokemon_rust/src/overworld/events/chained_events.rs | UTF-8 | 1,880 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | //! Generic event. Chains multiple events so that they happen sequentially.
use amethyst::ecs::World;
use super::{BoxedGameEvent, ExecutionConditions, GameEvent};
use std::collections::VecDeque;
#[derive(Default)]
pub struct ChainedEvents {
chain: VecDeque<Box<dyn GameEvent + Sync + Send>>,
called_start: bo... | true |
82fc4624de3387327760344c3b92d5966b84e96d | Rust | markafarrell/gtp_rust | /src/gtp_v1/packet/header.rs | UTF-8 | 24,432 | 3.15625 | 3 | [
"MIT"
] | permissive | use crate::field::*;
use byteorder::{ByteOrder, NetworkEndian};
use super::messages::MessageType;
pub mod extension_headers;
use extension_headers::{ExtensionHeader, ExtensionHeaderTraits};
/*
Bits
|------------------------------... | true |
d3eee10c32113f57e6dd821aeeee3a55d77ceac1 | Rust | MatrixMike/rust | /iter5.rs | UTF-8 | 271 | 2.546875 | 3 | [] | no_license | fn main() {
let numbers = vec![1i32];
let other_numbers: Vec<i32> = numbers.iter().collect();
let the_vocabulary: Vec<&Vocabulary> = vocabulary_context
.vocabularies
.iter()
.filter(|voc| voc.metadata.identifier == vocabulary_id)
.collect();
}
| true |
45e4d65a0ad420a388e8a594be5e695512df38ad | Rust | hppRC/competitive-hpp-rs | /src/prime/factors.rs | UTF-8 | 4,454 | 3.546875 | 4 | [
"MIT"
] | permissive | use num::traits::PrimInt;
use std::collections::HashMap;
/// ## Example:
/// ```
/// use competitive_hpp::prelude::*;
///
/// assert_eq!(2, 10u64.first_factor());
/// assert_eq!(vec![2, 5, 5], 50u64.factors());
/// assert_eq!(vec![2, 5], 50u64.factors_uniq());
/// assert!(7u64.is_prime());
///
/// let mut map: HashMap... | true |
1aa22709d154f97bf59b134629e9cb8e3d306246 | Rust | pavlus/rt-one-week-rust | /src/renderer/mod.rs | UTF-8 | 2,584 | 3.109375 | 3 | [
"MIT"
] | permissive | pub use rgb_renderer::RgbRenderer;
pub use rgb_renderer_unbiased::RgbRendererUnbiased;
pub use ttl_renderer::TtlRenderer;
use crate::hittable::Hittable;
use crate::ray::Ray;
use crate::vec::V3;
use std::str::FromStr;
mod rgb_renderer;
mod ttl_renderer;
mod rgb_renderer_unbiased;
#[derive(Debug)]
pub enum RendererT... | true |
defca01794dc1256d5656719f3c0df62749bdb4a | Rust | halhenke/git-global | /src/models/repowrap.rs | UTF-8 | 2,105 | 3.125 | 3 | [
"MIT"
] | permissive | use crate::models::{repo::Repo, repo_tag::RepoTag};
use itertools::Itertools;
use std::collections::{hash_map::RandomState, hash_set::HashSet};
use std::hash::{Hash, Hasher};
use std::iter::{Extend, FromIterator};
use std::path::Path;
#[derive(Serialize, Deserialize, Debug, PartialOrd, Ord, Clone)]
pub struct RepoWrap... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.