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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2020a421f7393fa363a00162894b1fc497703da6 | Rust | GuilhermeWerner/cargo-subcommand | /src/subcommand.rs | UTF-8 | 5,979 | 2.65625 | 3 | [
"MIT"
] | permissive | use crate::artifact::Artifact;
use crate::error::Error;
use crate::profile::Profile;
use crate::utils;
use std::io::BufRead;
use std::path::{Path, PathBuf};
use std::process::Command;
#[derive(Debug)]
pub struct Subcommand {
cmd: String,
args: Vec<String>,
package: String,
manifest: PathBuf,
target... | true |
1a4cd2b911fdb96567c8afbe3c80608742b707c7 | Rust | ElliottLester/euler | /src/q7.rs | UTF-8 | 220 | 2.71875 | 3 | [] | no_license | use utils::primes::PrimeIterator;
pub fn soln(input:usize) -> usize {
let test = PrimeIterator::new();
test.skip(input-1).next().unwrap_or(0)
}
#[cfg(test)]
#[test]
pub fn q7() {assert!(soln(10001) == 104743);}
| true |
d4061b530cdb951f2a041439e382a25bd7601062 | Rust | Samiisd/aws-battlesnack | /engine/src/engine/point.rs | UTF-8 | 721 | 3.234375 | 3 | [] | no_license | use serde::Deserialize;
use crate::engine::Movement;
#[derive(Deserialize, PartialEq, Eq, Debug, Copy, Clone, Hash)]
pub struct Point {
pub x: i32,
pub y: i32,
}
impl Point {
pub fn apply_mov(&self, mov: Movement) -> Point {
match mov {
Movement::Right => Point {
x: se... | true |
02a1d013d2b9f206d892396dfc1d309a814044dd | Rust | tylerwhall/rust | /src/test/compile-fail/issue-24805-dropck-child-has-items-via-parent.rs | UTF-8 | 1,436 | 3.015625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-other-permissive",
"MIT",
"Unlicense",
"BSD-3-Clause",
"bzip2-1.0.6",
"NCSA",
"ISC",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | true |
6ed4cf0c4fcc098bb08fb93fc1da180099bb124c | Rust | bef1re/aoc2020 | /day12/program1.rs | UTF-8 | 1,082 | 3.65625 | 4 | [] | no_license | use std::fs;
fn rotated(direction:usize, delta:i32) -> usize {
let delta_indexes: i32 = delta / 90;
return ((direction as i32 + delta_indexes + 4) % 4) as usize;
}
fn main() {
let mut location = (0i32, 0i32);
let mut direction: usize = 0;
let directions = vec!["E", "S", "W", "N"];
let conten... | true |
607fbc6841d9c900fcecf9329a33968594621d94 | Rust | acmcarther/next_space_coop | /cargo/vendor/serde-0.9.7/src/ser/mod.rs | UTF-8 | 30,623 | 2.765625 | 3 | [] | no_license | //! Generic data structure serialization framework.
//!
//! The two most important traits in this module are `Serialize` and
//! `Serializer`.
//!
//! - **A type that implements `Serialize` is a data structure** that can be
//! serialized to any data format supported by Serde, and conversely
//! - **A type that im... | true |
f6679211e60dd45dbba3a6c7442c0f451fdd4cde | Rust | ivardb/AdventOfCode2020 | /src/days/day23/mod.rs | UTF-8 | 437 | 2.640625 | 3 | [] | no_license | pub mod part1;
pub mod part2;
pub fn run() {
part1::run();
part2::run();
}
pub fn default_input() -> &'static str {
include_str!("input")
}
pub fn parse_input(input : &str) -> Vec<i64> {
input.chars().map(|c| c.to_digit(10).unwrap() as i64).collect()
}
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub... | true |
1f564a2fd20dd8de388946d073b2533e0923cacd | Rust | yeastplume/rust-sssmc39 | /src/util/encrypt.rs | UTF-8 | 6,760 | 2.65625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | // Copyright 2019 The Grin Developers
//
// 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 |
c89abbc51e120307a186758b3666d1ab860dc747 | Rust | thepowersgang/rust_os | /Usermode/loader/lib/lib.rs | UTF-8 | 2,044 | 2.640625 | 3 | [
"BSD-2-Clause"
] | permissive | // Tifflin OS - Userland loader interface
// - By John Hodge (thePowersGang)
//
// A dummy interface library that provides dynamically-linked interfaces to the loader
#![no_std]
#![crate_type="dylib"]
#![crate_name="loader"]
//extern crate std_rt;
extern crate syscalls;
use core::result::Result;
include!("../common.... | true |
f744a734979e463d3b8fe2c2f41536638564aad9 | Rust | Misha007007/approx_entropy | /src/sampling_method/bootstrap.rs | UTF-8 | 6,557 | 3.109375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use rand::{seq::SliceRandom, Rng};
use thiserror::Error;
use crate::{traits::SamplingMethod, utils::count_dup, NaiveEstimator};
#[derive(Debug, Clone)]
pub struct Bootstrap<R> {
num_groups: usize,
degree: usize,
unnorm_distr: Vec<usize>,
rng: R,
}
#[derive(Error, Debug)]
pub enum ConstructionError {
... | true |
8ea93767c7f12369486e0fa7e8de4ec58d6da568 | Rust | sandialabs/Polymers | /src/physics/single_chain/fjc/thermodynamics/isometric/legendre/py.rs | UTF-8 | 22,362 | 2.578125 | 3 | [
"BSD-3-Clause"
] | permissive | use pyo3::prelude::*;
use numpy::
{
IntoPyArray,
PyArrayDyn,
PyReadonlyArrayDyn
};
use crate::math::integrate_1d;
use crate::physics::single_chain::
{
ONE,
ZERO,
POINTS
};
pub fn register_module(py: Python<'_>, parent_module: &PyModule) -> PyResult<()>
{
let legendre = PyModule::new(py, "le... | true |
85984186793c390909a1a7ddb7aa82864116a050 | Rust | LambdaInnovation/mu | /src/client/editor/inspect.rs | UTF-8 | 5,659 | 2.703125 | 3 | [] | no_license | use imgui_inspect::{InspectRenderDefault, InspectArgsDefault, InspectRenderSlider, InspectArgsSlider};
use crate::math::*;
use imgui::*;
use serde::export::PhantomData;
use strum::*;
pub struct VecDefaultInspect<T, U = T> where U: InspectRenderDefault<T> {
marker: PhantomData<(T, U)>,
}
impl<T, TInspect> InspectR... | true |
29038e3f91fd4abe5a9dd7c562791b017ddef5dc | Rust | bendotc/rust | /src/test/run-pass/lib-sort.rs | UTF-8 | 747 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-1-Clause",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-public-domain",
"MIT",
"BSD-2-Clause",
"bzip2-1.0.6"
] | permissive | use std;
fn check_sort(vec[int] v1, vec[int] v2) {
auto len = std::vec::len[int](v1);
fn lteq(&int a, &int b) -> bool {
ret a <= b;
}
auto f = lteq;
auto v3 = std::sort::merge_sort[int](f, v1);
auto i = 0u;
while (i < len) {
log v3.(i);
assert (v3.(i) == v2.(i));
i += 1u;
}
}
fn main()... | true |
9828d6f787a1176e0f99d5930b5ea58787006f01 | Rust | lnds/exercism_rust_track | /robot-simulator/src/lib.rs | UTF-8 | 1,864 | 3.75 | 4 | [] | no_license | #[derive(PartialEq, Debug)]
pub enum Direction {
North,
East,
South,
West,
}
pub struct Robot {
x: i32,
y: i32,
d: Direction,
}
use Direction::{East, North, South, West};
impl Robot {
pub fn new(x: i32, y: i32, d: Direction) -> Self {
Robot { x, y, d }
}
pub fn turn_r... | true |
3fdd9c820064ab0c6cbc7ede2f5b991837aa4e14 | Rust | LaughingLemon/hello_rocket | /src/main.rs | UTF-8 | 1,525 | 2.84375 | 3 | [] | no_license | #[macro_use] extern crate rocket;
use rocket::{Build, Rocket};
use std::fs;
use rocket::form::Form;
use rocket::response::content;
use rocket::response::content::Html;
use rocket_dyn_templates::Template;
use std::collections::HashMap;
#[get("/")]
fn index() -> &'static str {
"hello world"
}
//Up to age 255
#[get... | true |
9a934da663ff31efa14465966aba47400f5d6fd5 | Rust | ToyVo/ToyVo.github.io | /src/json_resume.rs | UTF-8 | 4,721 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use serde::Deserialize;
#[derive(Debug, Clone, PartialEq, Deserialize, Default)]
pub struct JsonResume {
pub basics: Basics,
pub work: Vec<Work>,
pub volunteer: Vec<Volunteer>,
pub education: Vec<Education>,
pub awards: Vec<Award>,
pub certificates: Vec<Certificate>,
pub publications: Vec<P... | true |
7716982952719c088ba9ee5bae79b84340f65152 | Rust | RustCrypto/block-ciphers | /rc5/src/core/backend.rs | UTF-8 | 6,442 | 2.640625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | use core::{
cmp::max,
marker::PhantomData,
ops::{Add, Div, Mul, Sub},
};
use cipher::{
generic_array::{sequence::GenericSequence, ArrayLength, GenericArray},
inout::InOut,
typenum::{Diff, IsLess, Le, NonZero, Sum, U1, U2},
typenum::{Unsigned, U256},
};
use super::{
Block, BlockSize, Ex... | true |
4a811c07b1876567b387ab9eb4175d732aa1d333 | Rust | LimeEng/brainrust | /brainrust-engine/tests/integration_test.rs | UTF-8 | 2,442 | 2.828125 | 3 | [] | no_license | extern crate brainrust_engine;
use brainrust_engine::interpreter;
use brainrust_engine::interpreter::Interpreter;
use brainrust_engine::lexer;
use brainrust_engine::optimizer;
use brainrust_engine::parser;
use std::fs;
use std::str;
const PROGRAM_PREFIX: &str = "tests/programs/";
const PROGRAM_EXTENSION: &str = ".b";... | true |
4e36817c500115e43090f5ff812a8b9f6cf0fd2d | Rust | cab404/move-tools | /common/dnode-rest-client/src/blocking.rs | UTF-8 | 3,124 | 2.640625 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use diem::prelude::*;
use http::Uri;
use crate::ds::*;
pub type BlockOpt = Option<Block>;
pub struct BytesForBlock(Vec<u8>, Block);
impl BytesForBlock {
pub fn block(&self) -> u128 {
self.1
}
#[inline]
pub fn bytes(&self) -> &[u8] {
self.as_bytes()
}
pub ... | true |
2f24bd0948a3b9443b8955c507dbd8429449fa66 | Rust | alex-ozdemir/analyze-unsafe | /tests/compile-fail/wrapped-leak.rs | UTF-8 | 488 | 2.890625 | 3 | [] | no_license | #![feature(rustc_attrs)]
pub struct MyBox {
x: i32,
p: *const i32,
}
impl MyBox {
pub fn new(i: i32) -> MyBox {
let mut b = MyBox {
x: i,
p: 0 as *const i32,
};
b.p = &b.x;
b
}
pub fn get(&self) -> i32 {
unsafe { *self.p }
}
pu... | true |
e2a3bf64d343af0f1f2c4638926201a1fe503dc6 | Rust | podo-os/slam-viewer | /src/window/camera/frustrum.rs | UTF-8 | 753 | 2.609375 | 3 | [
"BSD-2-Clause"
] | permissive | use super::base::Camera;
use super::coord::CoordSystemRh;
use nalgebra::{Point3, Vector3};
use slam_cv::Number;
pub struct CameraFrustum<N>
where
N: Number,
{
pub eye: Point3<N>,
pub at: Point3<N>,
pub fovy: N,
pub znear: N,
pub zfar: N,
}
impl<N> Into<Camera<N>> for CameraFrustum<N>
where
... | true |
e9dc34863087d91ebfcf6e371af45f54a13791f3 | Rust | dora-gt/tower-web | /src/util/buf_stream/buf_stream.rs | UTF-8 | 3,489 | 3.390625 | 3 | [
"MIT"
] | permissive | use super::{Chain, Collect, FromBufStream, SizeHint};
use bytes::Buf;
use futures::{Async, Poll};
/// An asynchronous stream of bytes.
///
/// `BufStream` asynchronously yields values implementing `Buf`, i.e. byte
/// buffers.
pub trait BufStream {
/// Values yielded by the `BufStream`.
type Item: Buf;
/... | true |
031f40fd40f6e2fae7aaa5c7233116ce4c7af69e | Rust | NotGyro/Gestalt | /gestalt-core/src/world/voxelstorage.rs | UTF-8 | 8,662 | 3.1875 | 3 | [] | no_license | use std::fmt::Debug;
use std::hash::Hash;
use crate::common::voxelmath::*;
use super::{TileCoord, TilePos};
pub trait Voxel: Clone + Debug + PartialEq + Eq + Hash + Send {}
impl<T> Voxel for T where T: Clone + Debug + PartialEq + Eq + Hash + Send {}
/// Abstract categories of voxel errors allowing you to check
/// ... | true |
b02461254fe1dd4405a51d181dded26b7fdadb18 | Rust | BinaryMuse/advent-of-code-2017 | /rust/src/day02.rs | UTF-8 | 2,340 | 3.390625 | 3 | [] | no_license | use common;
use std::str::FromStr;
type Spreadsheet<T> = Vec<Vec<T>>;
pub fn run(_args: &[String]) {
let input = common::get_input("./inputs/02.txt").expect("expected input 02.txt");
let sheet = text_to_ss(&input);
println!("Part 1: {}", checksum(&sheet, row_checksum_hi_lo));
println!("Part 2: {}", ch... | true |
adbe901c2b86eb5e7d2f5b1bd72e855c479a6bd0 | Rust | wa7sa34cx/nag | /src/http.rs | UTF-8 | 1,334 | 2.734375 | 3 | [
"MIT"
] | permissive | use crossbeam_channel::Sender;
use simple_server::{Server, Method, StatusCode};
use crate::{Opts, BotUpdate};
#[allow(non_camel_case_types)]
pub struct HTTP_Notifier {
opts: Opts,
sender: Sender<BotUpdate>
}
impl HTTP_Notifier {
pub fn new(opts: &Opts, sender: &Sender<BotUpdate>) -> Self {
HTTP_... | true |
dcac28f3d242fa18c830dfd255b9d97afeeb313c | Rust | ce3tal/twilight | /http/src/request/guild/sticker/mod.rs | UTF-8 | 2,840 | 3.203125 | 3 | [
"ISC"
] | permissive | mod create_guild_sticker;
mod delete_guild_sticker;
mod get_guild_sticker;
mod get_guild_stickers;
mod update_guild_sticker;
pub use self::{
create_guild_sticker::CreateGuildSticker, delete_guild_sticker::DeleteGuildSticker,
get_guild_sticker::GetGuildSticker, get_guild_stickers::GetGuildStickers,
update_g... | true |
644eae02271852f1db37d0ad4c040d3977f4cebf | Rust | zengzhiying/programming_languages | /rust/rust-basics/src/basic_type.rs | UTF-8 | 4,077 | 3.59375 | 4 | [] | no_license | // 导入类型转换的包
use std::convert::TryInto;
// 基本数据类型
pub fn data_type_basic() {
// 自动推导 i32 let定义变量是只读的
let a = 10;
// 定义类型
let b: i32 = 20;
// 字面量类型注解
let c = 30i32;
// 或者是
let d = 30_i32;
let e = add(add(a, b), add(c, d));
let e1 = add1(&add1(&a, &b), &add1(&c, &d));
printl... | true |
8eb9a1d97d755e331631b8c7e3b31718394d318b | Rust | dcastelltort/pgexercises | /src/utils.rs | UTF-8 | 903 | 3.0625 | 3 | [] | no_license | use std::env;
use std::fmt;
use dotenv::dotenv;
use diesel::prelude::*;
use diesel::pg::PgConnection;
/// utiliy function to connect to Postgres
pub fn establish_connection() -> PgConnection {
dotenv().ok();
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
PgConnection::est... | true |
3bb0d003c702d71ece2f19ad62feb8061bba149c | Rust | alekratz/file-lang | /src/syn/ast.rs | UTF-8 | 12,043 | 2.71875 | 3 | [] | no_license | use crate::{
common::span::*,
syn::{op::*, token::TokenKind},
};
use derivative::Derivative;
use lazy_static::lazy_static;
use matches::matches;
use std::{
fmt::{self, Display, Formatter},
rc::Rc,
};
pub type Lookaheads = &'static [TokenKind];
fn op_binding_name(op: &[OpKind]) -> String {
assert!(... | true |
5eedb49a4b92f088ef359bc236ef3eb9f4fef1da | Rust | 4rbor/tq | /tests/piping.rs | UTF-8 | 1,171 | 2.703125 | 3 | [
"MIT"
] | permissive | use assert_cmd::prelude::*; // Add methods on commands
use predicates::prelude::*; // Used for writing assertions
use std::process::Command; // Run programs
mod common;
#[test]
fn test_basic_pipe_context() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("tq")?;
cmd
.arg("--file")
... | true |
81145ac364ac408db6b1bfe7d51995e58d1664b1 | Rust | Majavar/map-generator | /src/interpolate.rs | UTF-8 | 1,220 | 3.34375 | 3 | [] | no_license | use config::Interpolation;
pub trait Lerp {
fn lerp(v0: f64, v1: f64, f64: f64) -> f64;
fn linear(v0: f64, v1: f64, f64: f64) -> f64;
fn cubic(v0: f64, v1: f64, f64: f64) -> f64;
fn quintic(v0: f64, v1: f64, f64: f64) -> f64;
fn cosine(v0: f64, v1: f64, f64: f64) -> f64;
}
impl Lerp for f64 {
... | true |
22153e05bf476d36cc78c1b0279a977d5144d764 | Rust | njeisecke/umya-spreadsheet | /tests/integration_test.rs | UTF-8 | 6,638 | 2.9375 | 3 | [
"MIT"
] | permissive | extern crate umya_spreadsheet;
#[test]
fn read_and_wite() {
// reader
let path = std::path::Path::new("C:/spread_test_data/aaa.xlsx");
let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap();
let _ = book.get_sheet_mut(0).get_cell_mut("A1").set_value("TEST1");
let a1_value = book.get_sh... | true |
d0497f48021badfb54c7ce21cc5ea849887d364c | Rust | GRDN-SVS/scrutinizer-agent | /src/database/mongo.rs | UTF-8 | 1,345 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | use mongodb::{
error::{Error, ErrorKind},
options::ClientOptions,
Client, Database,
};
use std::sync::Arc;
use crate::models;
/// Connects to a mongodb database, being the only one
/// in charge of interacting directly with it.
pub struct MongoExecutor(Database);
impl MongoExecutor {
pub async fn new... | true |
120676f2ebff8ca0934448e9fa6964f6e7ecf692 | Rust | media-io/xml-schema | /xml_schema_derive/src/xsd/schema.rs | UTF-8 | 4,368 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::xsd::{
attribute, attribute_group, complex_type, element, import, qualification, simple_type,
Implementation, XsdContext,
};
use proc_macro2::TokenStream;
#[derive(Clone, Default, Debug, PartialEq, YaDeserialize)]
#[yaserde(
root="schema"
prefix="xs",
namespace="xs: http://www.w3.org/2001/XMLSchem... | true |
f29ec81f2b8a06e3d177d065ea4baa0fd2f200ea | Rust | actix/examples | /server-sent-events/src/broadcast.rs | UTF-8 | 2,310 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | use std::{sync::Arc, time::Duration};
use actix_web::rt::time::interval;
use actix_web_lab::sse::{self, ChannelStream, Sse};
use futures_util::future;
use parking_lot::Mutex;
pub struct Broadcaster {
inner: Mutex<BroadcasterInner>,
}
#[derive(Debug, Clone, Default)]
struct BroadcasterInner {
clients: Vec<sse... | true |
a0380a51fd74b2fb1b0aaa4f8ad65b742b97aae9 | Rust | shimomire/rfol | /src/tokenizer.rs | UTF-8 | 1,360 | 3.328125 | 3 | [
"Apache-2.0"
] | permissive | extern crate itertools;
use crate::data::*;
use itertools::Itertools;
#[derive(Debug)]
pub struct Tokenizer<'a> {
pub iter: std::str::Chars<'a>,
pub tokens: Vec<Token>,
}
impl<'a> Tokenizer<'a> {
pub fn new() -> Tokenizer<'a> {
Tokenizer {
iter: "".chars(),
tokens: Vec::ne... | true |
198d6600faf2249025bf982b78b592f6f4c1076b | Rust | Shnatsel/rustsec | /cargo-lock/src/package.rs | UTF-8 | 917 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Rust packages enumerated in `Cargo.lock`
mod checksum;
mod name;
mod source;
pub use self::{
checksum::Checksum,
name::Name,
source::{GitReference, SourceId, SourceKind},
};
pub use semver::Version;
use crate::dependency::Dependency;
use serde::{Deserialize, Serialize};
/// Information about a Rust ... | true |
97210c712f2b6a53a89ea6ebbc9d4d80cd1e6c33 | Rust | Intrainos/Goodbye2016 | /src/main.rs | UTF-8 | 512 | 2.8125 | 3 | [
"MIT"
] | permissive | extern crate chrono;
use chrono::*;
fn main() {
loop {
#[cfg(feature="default")]
let time = chrono::Local::now();
#[cfg(feature="UTC")]
let time = chrono::UTC::now();
#[cfg(feature="debug")]
println!("{}h {}m {}s", time.hour(), time.minute(), time.second());... | true |
97b0f6971850acfd3e04d10b0982e428e98ff1f9 | Rust | norse-rs/audir | /audir-examples/src/music.rs | UTF-8 | 3,952 | 2.546875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::instance::Instance;
use audir::{Device, Instance as InstanceTrait};
#[cfg(target_os = "android")]
use std::path::Path;
#[cfg(target_os = "android")]
pub fn load<P: AsRef<Path>>(path: P) -> Vec<u8> {
use std::ffi::CString;
use std::io::Read;
let filename = path.as_ref().to_str().expect("Can`t c... | true |
8249e9e5bb56cea8f8e35ffb42e7885f9822998b | Rust | rustkas/rust-by-example-imp | /rust-by-example/hermanradtke/src/string1.rs | UTF-8 | 514 | 3.234375 | 3 | [
"MIT"
] | permissive | // cargo run -p hermanradtke --bin string1
fn print_me(msg: &str) { println!("msg = {}", msg); }
fn main() {
let string = "hello world";
print_me(string);
let owned_string = "hello world".to_string(); // or String::from_str("hello world")
print_me(&owned_string);
let counted_string = std::rc::Rc... | true |
4e3903086b4c06ce95315fc7c20df3800c0cff43 | Rust | Funkschy/kantan | /src/resolve/symbol.rs | UTF-8 | 3,474 | 3.34375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use crate::types::*;
use crate::{Span, Spanned};
#[derive(Debug, Eq, PartialEq)]
pub enum SymbolKind {
Global,
Local,
Param,
}
#[derive(Debug, Eq, PartialEq)]
pub struct Symbol<'src> {
pub ty: Type<'src>,
pub kind: SymbolKind,
pub name: &'src str,
}
impl<'src> ... | true |
9d3a4d920522d630dd980581886dfb862da5ce7d | Rust | ProjectFrank/adventofcode2019 | /day7/src/lib.rs | UTF-8 | 3,989 | 3.265625 | 3 | [] | no_license | use intcode_computer::*;
use itertools::Itertools;
use std::collections::HashSet;
use std::i32;
mod pt1 {
use super::*;
fn helper(
raw_code: &str,
input: i32,
used_phase_settings: HashSet<i32>,
recursion_counter: u32,
biggest: &mut i32,
) {
if recursion_coun... | true |
ece3da72dd20c076acec808b6fd9c2a03e1ff18f | Rust | nervosnetwork/ckb | /script/src/type_id.rs | UTF-8 | 3,311 | 2.609375 | 3 | [
"MIT"
] | permissive | use crate::{ScriptError, ScriptGroup};
use ckb_hash::new_blake2b;
use ckb_types::{
core::{cell::ResolvedTransaction, Cycle},
prelude::*,
};
// NOTE: we give this special TYPE_ID script a large cycle on purpose. This way
// we can ensure that the special built-in TYPE_ID script here only exists for
// safety, n... | true |
5b55c448b942f10f968e4e14c566131d598ddf53 | Rust | Johan-Mi/derivative | /src/parser.rs | UTF-8 | 2,989 | 3 | 3 | [
"Unlicense"
] | permissive | use super::lexer::Token;
use super::types::{BinOperation, BinOperator, Expr, Number, Var};
use derive_more::Constructor;
use std::rc::Rc;
fn parse_var(tokens: &[Token]) -> Option<(Var, &[Token])> {
match tokens.split_first() {
Some((Token::Ident(symbol), tokens)) => {
Some((Var::new(symbol.to_s... | true |
e8627eca4113edb43c98d89bf5f73c32a6533a19 | Rust | windoze/tantivy | /src/reader/warming.rs | UTF-8 | 11,479 | 2.78125 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
use std::ops::Deref;
use std::sync::{Arc, Mutex, Weak};
use std::thread::JoinHandle;
use std::time::Duration;
use crate::{Executor, Inventory, Searcher, SearcherGeneration, TantivyError};
pub const GC_INTERVAL: Duration = Duration::from_secs(1);
/// `Warmer` can be used to maintain seg... | true |
8b0a1dac9d7fcaae4dd6f4d207b871c4c9e74685 | Rust | iCodeIN/advent-of-code-2019 | /3b.rs | UTF-8 | 2,239 | 3.25 | 3 | [] | no_license | use std::io;
use std::io::prelude::*;
use std::error::Error;
use std::collections::{HashSet, HashMap};
#[derive(Clone, Copy)]
enum Direction { U, D, R, L }
use Direction::*;
struct Move(Direction, usize);
fn trace(path: &[Move]) -> HashMap<(isize, isize), usize> {
let mut out = HashMap::new();
let mut steps ... | true |
0010198fe58f0c16a6acabcdad7f8eef685126a0 | Rust | koqizhao/rust-projects | /web-server/src/server_handler.rs | UTF-8 | 2,483 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use std::net::{ TcpStream, Shutdown };
use std::marker::PhantomData;
use serde::{ Serialize };
use serde::de::DeserializeOwned;
use crate::protocol::Protocol;
use crate::serializer::Serializer;
macro_rules! close_return {
($stream: ident, $e: ident) => (
{
println!("Error: {}", $e);
... | true |
3c1e7f5728723bbcf64c30d6777f3ec2a09b86ea | Rust | MikailBag/kube-utils | /example-lock/src/main.rs | UTF-8 | 2,066 | 2.578125 | 3 | [] | no_license | use anyhow::Context;
use kube_utils::lock::LockResult;
use std::time::Duration;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing::info!("Connecting to kube");
let k = kube::C... | true |
b1334c30dc3502ca0ea681e2f27c2e8dce51c472 | Rust | sherry255/porus | /src/list/iter.rs | UTF-8 | 1,373 | 3 | 3 | [
"MIT"
] | permissive | use super::{get, List};
use crate::collection;
use core::iter::{DoubleEndedIterator, ExactSizeIterator, Iterator};
pub struct ListIterator<'a, T: 'a + List>
where
T::Elem: Clone,
{
list: &'a T,
start: usize,
end: usize,
}
impl<'a, T: 'a + List> Iterator for ListIterator<'a, T>
where
T::Elem: Clone... | true |
e79fb9afacbf2b5a5bd2f34dd71f17d6120467d1 | Rust | ryanolf/rspotify | /src/clients/mutex/futures.rs | UTF-8 | 392 | 2.84375 | 3 | [
"MIT"
] | permissive | use futures::lock::{Mutex, MutexGuard};
#[derive(Debug, Default)]
pub struct FuturesMutex<T: ?Sized>(Mutex<T>);
#[derive(Debug)]
pub struct LockError;
impl<T> FuturesMutex<T> {
pub fn new(val: T) -> Self {
FuturesMutex(Mutex::new(val))
}
pub async fn lock(&self) -> Result<MutexGuard<'_, T>, Lock... | true |
f51226889150eb447552a58eb33166b712fdae65 | Rust | irevoire/stackvm | /examples/seq.rs | UTF-8 | 1,176 | 2.96875 | 3 | [] | no_license | //! This function provides an statement and
//! the corresponding manually written stackvm instructions.
use stackvm::{expr, inst, stmt};
use std::collections::HashMap;
fn main() {
let x = &expr::var("x");
let y = &expr::var("y");
let z = &expr::var("z");
let one = &expr::r#const(1);
let stmt = st... | true |
8aef60b329b17216fd437dd09665fd98b5ee427a | Rust | vintersnow/hackerrank.rs | /algorithms/graph_theory/roads_and_libraries/src/main.rs | UTF-8 | 1,822 | 3.1875 | 3 | [] | no_license | use std::io;
fn readint() -> usize {
let mut s = String::new();
io::stdin().read_line(&mut s).ok().expect("read error");
return s.trim().parse().ok().expect("parse error");
}
fn readvec() -> Vec<usize> {
let mut s = String::new();
io::stdin().read_line(&mut s).ok().expect("read error");
let spl... | true |
ad1f29e72616b5bf6407712820efb6b02aff42e1 | Rust | haodeng/rust_beginner | /src/iterators.rs | UTF-8 | 4,255 | 4 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | fn main() {
loop_iterator();
iterator_next();
iterator_sum();
produce_other_iterator();
test_filters_by_size();
calling_next_counter();
using_other_iterator_trait_methods();
}
fn loop_iterator() {
let v1 = vec![1, 2, 3];
// created an iterator. no iteration takes place here
... | true |
e17df46eb0031db8e75b19546ef41b49f8e2e614 | Rust | bombela/fwdlist | /src/ops/access.rs | UTF-8 | 1,002 | 3.25 | 3 | [] | no_license | use crate::List;
/// Some accessors to front/back elements.
impl<T> List<T> {
/// Returns a reference to the first element in the list.
pub fn front(&self) -> Option<&T> {
self.head.as_ref().map(|node| &node.value)
}
/// Returns a mutable reference to the first element in the list.
pub fn ... | true |
74240a7a59100a421ead33c012564fa7cadaadb0 | Rust | TrustTheRust/rust-actix-realworld-example-app | /src/app/users/register_user.rs | UTF-8 | 2,069 | 2.84375 | 3 | [] | no_license | use super::SignupUser;
use crate::db;
use crate::mdl::{NewUser, User};
use crate::password::CanHashPassword;
use crate::prelude::*;
register_service!(RegisterUser);
pub trait CanRegisterUser {
fn register_user(&self, form: &SignupUser) -> Result<User>;
}
pub trait RegisterUser: db::HaveConn + CanHashPassword {}
... | true |
fb518c910dbc61fe1828b9a4bdca947fdf309893 | Rust | e14tech/largest | /src/adder.rs | UTF-8 | 180 | 3.09375 | 3 | [
"BSD-2-Clause"
] | permissive | pub fn adder(numbers: &Vec<u64>) -> u128 {
let mut number_holder: u128 = 0;
for &item in numbers.iter() {
number_holder += item as u128;
}
number_holder
}
| true |
fc2dfd4e08e8447f4e459f9016eff4e6dc2a1fb9 | Rust | fogti/libnar | /src/ser.rs | UTF-8 | 4,412 | 3.046875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fs::{self, File};
use std::io::{self, Error, ErrorKind, Read, Write};
use std::os::unix::fs::MetadataExt;
use std::path::Path;
use crate::{NIX_VERSION_MAGIC, PAD_LEN};
pub fn to_vec<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
let mut buffer = Vec::new();
to_writer(&mut buffer, path)?;
Ok(bu... | true |
7a3b9a11439351d3cbb3c8f7490d84555cae6ac4 | Rust | Stoeoef/rstar | /rstar/src/test_utilities.rs | UTF-8 | 1,649 | 2.6875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::primitives::*;
use crate::{Point, RTreeObject};
use rand::distributions::Uniform;
use rand::{Rng, SeedableRng};
use rand_hc::Hc128Rng;
pub type Seed = [u8; 32];
pub const SEED_1: &Seed = b"wPYxAkIiHcEmSBAxQFoXFrpYToCe1B71";
pub const SEED_2: &Seed = b"4KbTVjPT4DXSwWAsQM5dkWWywPKZRfCX";
pub fn create_rando... | true |
ede209b9304ca45216a91caf59435a7558bcc4e5 | Rust | dylemma/procedural-dungeon-rs | /src/nav.rs | UTF-8 | 7,428 | 2.75 | 3 | [] | no_license | use bevy::prelude::*;
use parry2d::na::Isometry2;
use parry2d::query::PointQuery;
use crate::convert::*;
use crate::graph::*;
#[derive(Component)]
pub struct NavigationSpeed(pub f32);
#[derive(Component)]
pub struct NavigationCursor {
pub entity: Entity,
}
pub type NavPoint = (FloorNodeId, Vec2);
#[derive(Debu... | true |
bcc03a6e9873b91482440782f079b0b687b6649f | Rust | bitemyapp/imdb | /benches/bench_top250.rs | UTF-8 | 788 | 2.5625 | 3 | [
"MIT"
] | permissive | #![feature(test)]
extern crate test;
extern crate imdb;
extern crate glob;
use glob::glob;
use imdb::unstable::parser;
use std::fs::File;
use std::io::prelude::*;
#[bench]
fn bench_parse_top250_movies_html(b: &mut test::Bencher) {
for entry in glob("fixtures/top250movie*.html")
.expect("No file matching `... | true |
8726fd87c7f021f2a7cd645bdd7c0cfef70b8a96 | Rust | holg/rustlesnake | /src/snake/colors.rs | UTF-8 | 484 | 2.90625 | 3 | [] | no_license | pub enum Color {
Background,
GameOver,
SevenSegment,
ControlOverlay,
Snake,
Food,
PowerUp,
}
impl Color {
pub fn value(&self) -> u16 {
match *self {
Color::Background => 0x0000,
Color::GameOver => 0xBC00,
Color::SevenSegment => 0xFFFF,
... | true |
db766b7847b859e7fd4b069f9d04ac7aedffa0e7 | Rust | tianenchen/leetcode-rs | /src/leetcode/remove_duplicates.rs | UTF-8 | 2,040 | 3.484375 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn remove_duplicates(s: String, k: i32) -> String {
let mut times = std::collections::LinkedList::new();
let mut stack = std::collections::LinkedList::new();
for c in s.chars() {
if stack.is_empty() || *stack.back().unwrap() != c {
... | true |
627f35d859b51c69f93307aedd7588b15d988547 | Rust | reitermarkus/dockworker | /src/hyper_client.rs | UTF-8 | 4,044 | 2.5625 | 3 | [] | no_license | use std::fs::File;
use std::path::Path;
use std::result;
#[cfg(feature = "openssl")]
use std::sync::Arc;
use hyper::client::response::Response;
use hyper::header::Headers;
use hyper::net::HttpConnector;
#[cfg(feature = "openssl")]
use hyper::net::{HttpsConnector, Openssl};
use hyper::Client;
use url::Url;
#[cfg(featur... | true |
c870feae3b7a8f1794d96fbe961cbc9a3279299e | Rust | wangyu190810/pythonvm-rust | /src/processor/mod.rs | UTF-8 | 28,719 | 2.609375 | 3 | [] | no_license | pub mod instructions;
pub mod frame;
use super::objects::{ObjectRef, ObjectContent, Object};
use super::varstack::VarStack;
use self::instructions::{CmpOperator, Instruction};
use self::frame::{Block, Frame};
use std::fmt;
use std::collections::HashMap;
use std::io::Read;
use std::cell::RefCell;
use std::rc::Rc;
use s... | true |
755328df35271e72b0e0ea9db42c80968ef75cf8 | Rust | yxxx5/leetcode_rust | /src/three_sum/mod.rs | UTF-8 | 1,771 | 3.40625 | 3 | [] | no_license | /*
执行用时: 32 ms, 在3Sum的Rust提交中击败了100.00% 的用户
内存消耗: 1.9 MB, 在3Sum的Rust提交中击败了100.00% 的用户
O(n2)
思路:双指针,遍历Vec 取末尾值nums[i] i = len - 1,
双指针r -> 0 l -> i - 1
问题就转为 nums[r] + nums[l] == -nums[i]
*/
struct Solution15{
}
impl Solution15 {
pub fn three_sum(mut nums: Vec<i32>) -> Vec<Vec<i32>> {
... | true |
32f95bf9fc4582209fed644e71814aa177d2361b | Rust | nilsso/mips-rs | /mips-parser/src/ast/nodes/arg.rs | UTF-8 | 1,903 | 2.984375 | 3 | [] | no_license | use std::{fmt, fmt::Display};
use pest::iterators::Pair;
use util::is_as_inner;
use crate::Rule;
use crate::ast::{Node, pair_to_float, FirstInner, AstError, AstResult};
use super::{Mem, Dev, Val};
/// Function argument node.
#[derive(Clone, PartialEq, Debug)]
pub enum Arg {
ArgMem(Mem),
ArgDev(Dev),
Ar... | true |
e52a7c5b016785a069d34b9497e122cedc650a3b | Rust | dduchen/rs-gfatovcf | /src/variant_identification.rs | UTF-8 | 33,582 | 2.59375 | 3 | [] | no_license | use handlegraph::handle::{Direction, Handle, NodeId};
use handlegraph::handlegraph::handle_edges_iter;
use handlegraph::handlegraph::HandleGraph;
use handlegraph::hashgraph::HashGraph;
use std::collections::BTreeMap; //like hashmap but sorted
use std::collections::HashMap;
extern crate chrono;
use crate::bubble_detecti... | true |
64c2b93a94b529ab608758ecba98e08d54c2ce1b | Rust | f6queer/vote-bot | /src/poll_token.rs | UTF-8 | 2,502 | 2.71875 | 3 | [] | no_license | use crate::constants::*;
use aes_gcm_siv::aead::{generic_array::GenericArray, Aead, NewAead};
use aes_gcm_siv::Aes256GcmSiv;
use rand::prelude::*;
use telegram_bot::types::{MessageId, UserId};
#[derive(Clone, Debug)]
pub struct PollToken {
pub token: String,
pub user_id: UserId,
pub msg_id: MessageId,
}
i... | true |
024d83c8fc581281b66db470e035fb41a78fc81d | Rust | AlisCode/AdventOfCode2017 | /day18_parser/src/lib.rs | UTF-8 | 2,751 | 3.078125 | 3 | [] | no_license | #[macro_use]
extern crate nom;
use nom::{alphanumeric, digit, space};
use std::str;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub enum Action {
Sound,
Set,
Add,
Mul,
Modulo,
Receive,
JumpGreaterZero,
}
impl Action {
fn from_str(input: &str) -> Action {
match inpu... | true |
76b5ced5ecf0aa4ed20f2e0b4002c4807d8d0089 | Rust | dakom/simple-html-template | /src/lib.rs | UTF-8 | 8,245 | 2.625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::collections::HashMap;
mod errors;
#[cfg(test)]
mod tests;
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;
#[cfg(feature = "wasm")]
use wasm_bindgen::JsCast;
#[cfg(feature = "wasm")]
use web_sys::{Document, DocumentFragment, HtmlTemplateElement, HtmlElement};
pub use errors::{Error, Errors};
#[macro_e... | true |
ad2950d1882ab78adc4fe645797d1a2526defd34 | Rust | grovesNL/glow | /src/version.rs | UTF-8 | 7,117 | 3.515625 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"Zlib"
] | permissive | /// A version number for a specific component of an OpenGL implementation
#[derive(Clone, Eq, Ord, PartialEq, PartialOrd)]
pub struct Version {
pub major: u32,
pub minor: u32,
pub is_embedded: bool,
pub revision: Option<u32>,
pub vendor_info: String,
}
impl Version {
/// Create a new OpenGL ver... | true |
76e159dd67f6bd7ea584cbdb97da7cff4ef265bb | Rust | michaeljones/elm-parser | /src/ast/statement/module.rs | UTF-8 | 6,346 | 2.71875 | 3 | [] | no_license | use ast::helpers::{lo_name, module_name, spaces, spaces_or_new_lines_and_indent, up_name, IR};
use ast::statement::core::Statement;
use ast::statement::export::exports;
use nom::types::CompleteStr;
named!(pub port_module_declaration<CompleteStr, Statement>,
do_parse!(
tag!("port") >>
call!(spaces_or_new_lin... | true |
ae633521f962e6b77fef2c5a111565086790f584 | Rust | hal2069/borrow-checker | /examples/structs/main.rs | UTF-8 | 312 | 3.78125 | 4 | [] | no_license | struct Circle {
radius: &f32,
}
impl Circle {
fn area(&self) -> f32 {
self.radius * self.radius * std::f32::consts::PI
}
}
fn main() {
let circle = {
let radius = 7.0f32;
Circle {
radius: &radius,
}
};
println!("Area: {}", circle.area());
}
| true |
7fee719be67652dc607b403f74e01719dd1c839b | Rust | janhrastnik/chip8-rust | /src/main.rs | UTF-8 | 16,207 | 2.6875 | 3 | [] | no_license | use minifb::{Key, KeyRepeat, Window, WindowOptions};
use rand::Rng;
use std::time::{Duration, Instant};
fn main() {
let fontset = vec![
0xF0, 0x90, 0x90, 0x90, 0xF0, //0
0x20, 0x60, 0x20, 0x20, 0x70, //1
0xF0, 0x10, 0xF0, 0x80, 0xF0, //2
0xF0, 0x10, 0xF0, 0x10, 0xF0, //3
0x9... | true |
fcdb374bb77467cb9fe6564e984baa4012834915 | Rust | haramako/work | /rlang/src/parser.rs | UTF-8 | 3,905 | 2.84375 | 3 | [] | no_license | use nom_locate::LocatedSpan;
use nom_recursive::{recursive_parser, RecursiveInfo};
use std::fmt;
use nom::{
branch::*,
bytes::complete::*,
character::complete::*,
combinator::{map, map_res},
multi::*,
sequence::*,
IResult,
};
type Span<'a> = LocatedSpan<&'a str, RecursiveInfo>;
#[derive(C... | true |
126a616d48fd04375d5ecc56f9821fea3151e93c | Rust | maekawatoshiki/XScript | /src/node.rs | UTF-8 | 900 | 3.296875 | 3 | [
"MIT"
] | permissive | use std::ops::Range;
use std::boxed::Box;
use typing::Type;
#[derive(Debug, Clone, PartialEq)]
pub struct Node {
pub kind: NodeKind, // The kind this node represents
pub range: Range<usize>, // The range within this node (for error handler)
}
impl Node {
pub fn new(kind: NodeKind, range: Range<usize... | true |
28d0f0fc6ace84d01ff3d6ccc24423180c6a0619 | Rust | microcluster/devand | /devand-core/src/auth.rs | UTF-8 | 1,600 | 3.875 | 4 | [
"Apache-2.0"
] | permissive | fn has_lowercase(s: &str) -> bool {
s.chars().any(|x| x.is_ascii_lowercase())
}
fn has_number(s: &str) -> bool {
s.chars().any(|x| x.is_ascii_digit())
}
/// Make sure it's at least 15 characters OR at least 8 characters including a
/// number and a lowercase letter.
pub fn is_valid_password(s: &str) -> bool {... | true |
0a014774e2e4c19621bda4182baf8be5d1c81eb0 | Rust | csherratt/hairball | /src/geometry/lib.rs | UTF-8 | 2,472 | 2.8125 | 3 | [] | no_license | extern crate capnp;
extern crate hairball;
#[cfg(feature="build-schema")]
pub mod geometry_capnp {
include!(concat!(env!("OUT_DIR"), "/geometry_capnp.rs"));
}
#[cfg(not(feature="build-schema"))]
pub mod geometry_capnp;
const COLUMN_NAME: &'static str = "geometry";
#[derive(Copy, Debug, Clone)]
pub struct Geomet... | true |
4331aba66312c6650fafcc02e61bd444ae9f8ef4 | Rust | FrancisMurillo/rust-mal | /mal-repl/tests/repl_test.rs | UTF-8 | 403 | 2.609375 | 3 | [] | no_license | use mal::{repl_parse, Err as ParseErr, Node};
#[test]
fn delimited_expressions_can_be_incomplete() {
for ch in "([{\"".chars() {
match repl_parse(&ch.to_string()) {
Err(ParseErr::Incomplete(_)) => (),
_ => panic!("{} should be incomplete", ch),
}
}
}
#[test]
fn parsing_... | true |
70cd1c113f66ea669829b85cc1ffc5a78140dbfd | Rust | mmrath/rust-experiment | /server/src/core/model.rs | UTF-8 | 433 | 2.734375 | 3 | [] | no_license | use std::rc::Rc;
#[derive(Serialize, Deserialize)]
pub struct Permission {
pub id: u32,
pub resource: String,
pub access: Access,
}
#[derive(Clone, Copy, Serialize, Deserialize)]
pub enum Access {
READ,
CREATE,
UPDATE,
DELETE,
ADMIN,
}
#[derive(Serialize, Deserialize)]
pub struct Role... | true |
159065eeae174a459adfb39d3c2783d7ec3bdfef | Rust | ibuystuff/differential-datalog | /rust/template/observe/observable.rs | UTF-8 | 459 | 2.828125 | 3 | [
"MIT"
] | permissive | use std::fmt::Debug;
use super::Observer;
use super::Subscription;
/// A trait for objects that can be observed.
pub trait Observable<T, E>: Debug
where
T: Send,
E: Send,
{
/// An Observer subscribes to an Observable to listen to data
/// emitted by the latter. The Observer stops listening when
//... | true |
6eaafee03b4692ec03b00e82b486d5ecf7836f1e | Rust | XiangQingW/rust-protobuf | /protobuf-codegen/src/well_known_types.rs | UTF-8 | 1,252 | 2.640625 | 3 | [
"BSD-2-Clause"
] | permissive | static NAMES: &'static [&'static str] = &[
"Any",
"Api",
"BoolValue",
"BytesValue",
"DoubleValue",
"Duration",
"Empty",
"Enum",
"EnumValue",
"Field",
// TODO: dotted names
"Field.Cardinality",
"Field.Kind",
"FieldMask",
"FloatValue",
"Int32Value",
"Int... | true |
cdd49c55eeb1debec00aba92167f40cd38022f7e | Rust | artemkoff/pokemon-api | /src/api/v2/resource.rs | UTF-8 | 8,971 | 2.625 | 3 | [
"MIT"
] | permissive | use crate::Result;
use async_trait::async_trait;
#[async_trait]
pub trait ApiResource {
type ResourceType: Sized;
fn url(&self) -> String;
async fn get(&self) -> Result<Self::ResourceType>;
}
#[async_trait]
pub trait ApiNamedResource: ApiResource {
fn name(&self) -> String;
}
#[rustfmt::skip]
#[asy... | true |
78291f775275f23bab836fd74a15dc6f8d0a3d2c | Rust | fabianschuiki/llhd | /src/pass/gcse.rs | UTF-8 | 6,481 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright (c) 2017-2021 Fabian Schuiki
//! Global Common Subexpression Elimination
use crate::{
ir::{prelude::*, InstData},
opt::prelude::*,
};
use std::collections::{HashMap, HashSet};
/// Global Common Subexpression Elimination
///
/// This pass implements global common subexpression elimination. It tri... | true |
f4ffb906d4a12a5d508c5f430ee990072c393c31 | Rust | veverkap/ruby-version-badger | /src/config.rs | UTF-8 | 509 | 3.390625 | 3 | [
"MIT"
] | permissive | use std::env;
pub fn port() -> String {
let mut p = String::from("3000");
match env::var("PORT") {
Ok(val) => p = val,
Err(_e) => println!("using default port {}", p),
}
return p;
}
#[cfg(test)]
mod tests {
use config;
use std::env;
#[test]
fn default_to_port_3k... | true |
533692fa58722e25619c2f5bfdb3ac0365121090 | Rust | emilsivervik/tictactoe | /src/assets/mod.rs | UTF-8 | 1,149 | 2.578125 | 3 | [] | no_license | use piston_window::*;
use sdl2_window::*;
use crate::globals;
pub struct Assets {
pub px_plus_font: Glyphs,
}
const FONT_FOLDER: &str = "assets/fonts";
const PX_PLUS_FONT: &str = "PxPlus_IBM_VGA8.ttf";
impl Assets {
pub fn new(_window: &mut PistonWindow<Sdl2Window>) -> Self {
let font_folder = find_... | true |
c4a0807d2c83e76ce0f35ad23992bcab69f502f0 | Rust | emirayka/nia_interpreter_core | /src/interpreter/library/keys/action/define_action.rs | UTF-8 | 2,378 | 3.046875 | 3 | [
"MIT"
] | permissive | use crate::Action;
use crate::Error;
use crate::Interpreter;
use crate::library;
pub fn define_action<S>(
interpreter: &mut Interpreter,
action_name: S,
action: &Action,
) -> Result<(), Error>
where
S: AsRef<str>,
{
let action_name = action_name.as_ref();
let action_value = library::action_to_... | true |
75b353deb030e42a9f9b748e18e2cf617a5e13b7 | Rust | joelhans/vector | /src/tls/settings.rs | UTF-8 | 14,224 | 2.53125 | 3 | [
"Apache-2.0",
"OpenSSL"
] | permissive | use super::{
AddCertToStore, AddExtraChainCert, DerExportError, FileOpenFailed, FileReadFailed, MaybeTls,
NewStoreBuilder, ParsePkcs12, Pkcs12Error, PrivateKeyParseError, Result, SetCertificate,
SetPrivateKey, SetVerifyCert, TlsError, TlsIdentityError, X509ParseError,
};
use openssl::{
pkcs12::{ParsedPk... | true |
21a094f2d185a04c6206178df63e8f349be1bea9 | Rust | MikailBag/jjs-pps | /svaluer/src/tests.rs | UTF-8 | 8,850 | 2.625 | 3 | [] | no_license | use super::*;
use status_util::{make_err_status, make_ok_status};
use std::collections::VecDeque;
use valuer_api::{
JudgeLog, JudgeLogSubtaskRow, JudgeLogTestRow, Status, SubtaskId, SubtaskVisibleComponents,
TestVisibleComponents,
};
#[derive(Debug)]
struct TestMock {
test_id: TestId,
live: bool,
s... | true |
13c5b53399c97233a95baa4a9770b19df4dccd50 | Rust | pipe-fun/pipe | /src/services/requests.rs | UTF-8 | 4,321 | 2.96875 | 3 | [
"MIT"
] | permissive | use serde::{
Deserialize,
Serialize,
};
use yew::format::{
Json,
Nothing,
Text,
};
use yew::services::fetch::{
FetchService,
FetchTask,
Request,
Response,
FetchOptions,
Credentials,
};
use yew::callback::Callback;
use dotenv_codegen::dotenv;
use crate::error::Error;
use cr... | true |
1f0428591b3e513a2b03843a3a019e50471a273c | Rust | Giovanni-Tedesco/tsp_2 | /src/plot/mod.rs | UTF-8 | 762 | 2.75 | 3 | [] | no_license | use gnuplot::{AxesCommon, Figure, PlotOption::Caption};
use crate::{city::Map, cycle::Cycle};
pub fn plot_graph(cycle: &Cycle, town_map: &Map) {
let (x, y) = generate_inputs(cycle, town_map);
let mut fg = Figure::new();
fg.axes2d().set_title("TSP Shortest Path", &[])
.lines(
&x,
&y,
... | true |
c9f3adb8dbd89da27a62d16e43c4c5643d08ca40 | Rust | lock19960613/SCL | /Daily/Rust/Leetcode523-连续的子数组和.rs | UTF-8 | 632 | 2.890625 | 3 | [] | no_license | use std::collections::HashMap;
impl Solution {
pub fn check_subarray_sum(nums: Vec<i32>, k: i32) -> bool {
let n = nums.len();
if n < 2 {
return false;
}
let mut re = 0;
let mut mp = HashMap::new();
mp.insert(0, -1 as i32);
for i in 0..n{
... | true |
8702e0a717e6edbc20369b4575548fd4d7da48ae | Rust | TonalidadeHidrica/taiko-untitled | /src/assets.rs | UTF-8 | 6,756 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::audio::{AudioManager, SoundBuffer};
use crate::errors::{new_sdl_error, TaikoError, TaikoErrorCause};
use crate::game::AutoEvent;
use sdl2::image::LoadTexture;
use sdl2::render::{Texture, TextureCreator, TextureQuery};
use sdl2::video::WindowContext;
use std::fmt::Debug;
use std::path::Path;
pub struct Asset... | true |
c133cb998099ca04047820b27e686887f1d67621 | Rust | zyhong/tickrs | /src/widget/add_stock.rs | UTF-8 | 2,260 | 2.6875 | 3 | [
"MIT"
] | permissive | use tui::buffer::Buffer;
use tui::layout::{Alignment, Rect};
use tui::style::Modifier;
use tui::text::{Span, Spans};
use tui::widgets::{Paragraph, StatefulWidget, Widget, Wrap};
use super::block;
use crate::common::ChartType;
use crate::theme::style;
use crate::THEME;
pub struct AddStockState {
search_string: Str... | true |
aa80453a00a3a9113a90c4668762f91f60ab3303 | Rust | gbip/rust-render-engine | /src/filter/mod.rs | UTF-8 | 782 | 3.015625 | 3 | [] | no_license | pub mod filters;
use color_float::LinearColor;
use renderer::Pixel;
use filter::filters::{BoxFilter, MitchellFilter};
/** Un trait qui représente un filtre */
pub trait Filter {
fn compute_color(&self, data: &Pixel, position: (u32, u32)) -> LinearColor;
}
#[derive(Serialize,Deserialize, Debug)]
pub enum FilterFa... | true |
e7d6a741eb560cba2b68d1e2f76cf4daaac04dd0 | Rust | btwotwo/chip8rust | /src/opcode/opcodes_tests.rs | UTF-8 | 6,923 | 2.859375 | 3 | [] | no_license | use super::*;
fn prepare() -> Chip {
Chip::new()
}
#[test]
fn ret_test() {
let mut chip = prepare();
chip.stack_pointer = 10;
chip.stack[chip.stack_pointer as usize] = 0x1234;
OpcodeHandler::ret(0x00EE, &mut chip);
assert_eq!(chip.program_counter, 0x1234);
assert_eq!(chi... | true |
51029ea746207eabf04570680ce88de209bf203f | Rust | adrianchitescu/aoc20-rs | /day7/src/main.rs | UTF-8 | 2,406 | 3.25 | 3 | [] | no_license | use std::env;
use std::fs;
use std::collections::HashMap;
#[derive(Debug)]
struct Rules(HashMap<String, Vec<(usize, String)>>);
fn parse_input(input: &String) -> Rules {
input
.lines()
.filter(|l| !l.is_empty())
.fold(Rules(HashMap::new()), |mut r, line| {
let parts:Vec<&str> = ... | true |
7c15d8cbcd9a7c69a2c129f3c645e2bf355f8ccf | Rust | asp2insp/lodestone | /src/slicebtree/mod.rs | UTF-8 | 938 | 2.640625 | 3 | [
"MIT"
] | permissive | /// 2-headed, Copy-on-Write B+Tree map
/// Supports MVCC up to 2 revisions
/// Lives entirely within the slice that is given to it.
/// Keys and Values are byte slices.
use self::node::*;
use std::sync::atomic::AtomicUsize;
use allocator::*;
pub mod node;
pub const N: usize = 2;
pub const B: usize = 100;
pub const NO... | true |
6ef3e6c96516082db33fcd8d512c1b216db0962e | Rust | cdong1012/RustOS | /kern/src/elfparser/dynamic.rs | UTF-8 | 10,073 | 2.71875 | 3 | [] | no_license | use shim::const_assert_size;
use core::fmt::Error;
use alloc::vec::Vec;
use crate::console::{kprintln, kprint};
use crate::elfparser::section::{SectionTable, SectionEntry64};
use crate::elfparser::values::*;
//https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-42444.html
#[derive(Debug, Default, Clone)]
pub st... | true |
ea109614255676082f58f14f242c1d09024e4d63 | Rust | tailhook/bulk | /src/config.rs | UTF-8 | 3,132 | 2.671875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::path::{Path, PathBuf};
use quire::validate::{Sequence, Structure, Enum, Nothing, Numeric, Scalar};
use quire::{parse_config, Options};
use version::Version;
use bulk_version::MinimumVersion;
#[derive(Deserialize, Clone, Debug)]
pub struct Metadata {
pub name: String,
pub short_description: String,
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.