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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
67c82c949071014260174b7334843321e72c3486 | Rust | jacobrosenthal/hf2-rs | /hf2/src/bininfo.rs | UTF-8 | 3,435 | 2.984375 | 3 | [
"MIT"
] | permissive | use crate::command::{rx, xmit, Command, CommandResponse, CommandResponseStatus};
use crate::Error;
use core::convert::TryFrom;
use scroll::{ctx, Pread, LE};
#[derive(Debug, PartialEq)]
pub enum BinInfoMode {
//bootloader, and thus flashing of user-space programs is allowed
Bootloader = 0x0001,
//user-space... | true |
4beeddbe8a48773dcb575db562c7c2f2642feb8b | Rust | AndrewMendezLacambra/rust-programming-contest-solutions | /atcoder/arc074_d.rs | UTF-8 | 5,517 | 2.796875 | 3 | [] | no_license | fn main() {
let (r, w) = (std::io::stdin(), std::io::stdout());
let mut sc = IO::new(r.lock(), w.lock());
let h: usize = sc.read();
let w: usize = sc.read();
let board = (0..h).map(|_| sc.chars()).collect::<Vec<_>>();
let mut dinitz = dinitz::Dinitz::new(h + w + 2);
let source = h + w;
... | true |
a8b36367f5b59875587ba0b04a47d00be05771dd | Rust | nilq/hugorm | /src/hugorm/prelude/math.rs | UTF-8 | 1,567 | 2.78125 | 3 | [
"MIT"
] | permissive | use super::visitor::*;
use zub::ir::*;
use zub::vm::*;
use statrs::distribution::StudentsT;
use statrs::statistics::*;
pub fn include_math(visitor: &mut Visitor, vm: &mut VM) {
visitor.set_global("sum", TypeNode::Func(1));
vm.add_native("sum", sum, 1);
visitor.set_global("student", TypeNode::Func(3));
... | true |
d6d0ba64f805e6b7a9e03c4032e40561a9f1f704 | Rust | tuplecats/docker-client | /src/container/inspect/request.rs | UTF-8 | 433 | 2.84375 | 3 | [
"MIT"
] | permissive |
pub struct Inspect {
id: String,
size: Option<bool>
}
impl Inspect {
pub fn container(_id: String) -> Self {
Inspect {
id: _id,
size: None
}
}
pub fn size(&mut self, v: bool) {
self.size = Some(v);
}
pub fn get_path(&self) -> String {
... | true |
9161c14d4f423e1ebfcc14d315e036ea1c4e9040 | Rust | kitagawa-hr/Project_Euler | /rust/q002.rs | UTF-8 | 354 | 3.375 | 3 | [] | no_license | fn fibo(x: i32) -> i32 {
if x == 1 || x == 2 {
x
} else {
fibo(x - 1) + fibo(x - 2)
}
}
fn main() {
let mut x: i32 = 1;
let mut ans: i32 = 0;
let mut f: i32 = 0;
while f <= 4000000 {
f = fibo(x);
x += 1;
if f % 2 == 0 {
ans += f;
}... | true |
cb59027585ec8d6a4fb9b659052a2e1a4544cc38 | Rust | aehernandez/Rump | /src/options.rs | UTF-8 | 3,338 | 2.796875 | 3 | [
"MIT"
] | permissive | use rustc_serialize::{Encodable, Encoder};
/// Represents different Options that can be sent wth a WAMP event
#[derive(RustcDecodable, Debug, Clone, PartialEq)]
pub enum Options {
// TODO: // different options
Empty,
}
impl Encodable for Options {
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::... | true |
d510b56a2a8704304c48736b8ba5b8640703dfb7 | Rust | Gisleburt/Skitty | /src/bin/skitty.rs | UTF-8 | 2,180 | 2.796875 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate clap;
extern crate skitty;
use clap::App;
use skitty::{
extract,
combine,
watch,
};
fn main() {
let yaml = load_yaml!("skitty.yaml");
let mut app = App::from_yaml(yaml)
.about(env!("CARGO_PKG_DESCRIPTION"))
.author(env!("CARGO_PKG_AUTHORS"))
.ver... | true |
f4d01eeadda38b809ecbcd78604c7cd9bcde1996 | Rust | lgcaobianco/rustlearning | /data_types_and_functions/src/main.rs | UTF-8 | 1,129 | 3.90625 | 4 | [] | no_license | use std::io;
fn main() {
let a = [10, 20, 30, 40, 50];
let mut index = 0;
while index < 5 {
println!("no index {} o valor eh {}", index, a[index]);
index = index + 1;
}
let mut entrada = String::new();
println!("digite a temperatura");
io::stdin().read_line(&mut entrada)
... | true |
a83ec3b426143e78c163dbc9f04562a00d359c42 | Rust | ackintosh/sandbox | /rust/leetcode/src/matrix_block_sum.rs | UTF-8 | 2,298 | 3.109375 | 3 | [] | no_license | // https://leetcode.com/problems/matrix-block-sum/
// Hints:
// 1. How to calculate the required sum for a cell (i,j) fast ?
// 2. Use the concept of cumulative sum array.
// 3. Create a cumulative sum matrix where dp[i][j] is the sum of all cells in the rectangle from (0,0) to (i,j), use inclusion-exclusion idea.
// ... | true |
e452e775daf733c97dfa353da156de13cf6d3d05 | Rust | KuldeepSinh/trpl_notes | /15_chapter/boxes/src/main.rs | UTF-8 | 2,442 | 4.21875 | 4 | [
"Apache-2.0"
] | permissive | //A pointer is a general concept for a variable that contains an address in memory.
// The most common kind of pointer in Rust is a reference.
//"References" are indicated by the & symbol and borrow the value they point to.
//"Smart pointers", on the other hand, are data structures that not only act like
//a pointer b... | true |
af5312a26e1519bbe6e73d5785b1ac9c386e1caf | Rust | RoaringBitmap/roaring-rs | /tests/is_subset.rs | UTF-8 | 2,214 | 2.859375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate roaring;
use roaring::RoaringBitmap;
#[test]
fn array_not() {
let sup = (0..2000).collect::<RoaringBitmap>();
let sub = (1000..3000).collect::<RoaringBitmap>();
assert!(!sub.is_subset(&sup));
}
#[test]
fn array() {
let sup = (0..4000).collect::<RoaringBitmap>();
let sub = (2000..3000)... | true |
615441db03469204c1fbd5f7bde15d455bcd184a | Rust | l3kn/EulerLisp | /src/vm/mod.rs | UTF-8 | 25,510 | 2.703125 | 3 | [
"MIT"
] | permissive | //! Virtual Machine
use std::cell::RefCell;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::convert::TryInto;
use std::fs;
use std::fs::File;
use std::io::{Read, Write};
use std::rc::Rc;
use crate::builtin::{self, BuiltinRegistry};
use crate::compiler::{Compiler, Program};
use crate::env::{Env, EnvRef... | true |
f42d733144dd251a87830fd706ee378f2ad9fad1 | Rust | hegza/isosurface | /src/index_cache.rs | UTF-8 | 3,064 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2018 Tristam MacDonald
//
// 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 agreed ... | true |
adf102cdf39694a2056a64a6d86b036aebc2777a | Rust | tirust/msp432e4 | /src/sysctl/sruart.rs | UTF-8 | 13,575 | 2.8125 | 3 | [
"BSD-3-Clause"
] | 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::SRUART {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &... | true |
43be7cefd7ae5d0d2340741db8d8c37c43149190 | Rust | bevyengine/bevy | /examples/ui/flex_layout.rs | UTF-8 | 6,499 | 3.046875 | 3 | [
"Apache-2.0",
"MIT",
"Zlib",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive"
] | permissive | //! Demonstrates how the `AlignItems` and `JustifyContent` properties can be composed to layout text.
use bevy::prelude::*;
const ALIGN_ITEMS_COLOR: Color = Color::rgb(1., 0.066, 0.349);
const JUSTIFY_CONTENT_COLOR: Color = Color::rgb(0.102, 0.522, 1.);
const MARGIN: Val = Val::Px(5.);
fn main() {
App::new()
... | true |
f9c0f0b78662afe78301f4bc1c73240fc56e67da | Rust | oletalk/langside | /rust/matching_on_options.rs | UTF-8 | 881 | 3.25 | 3 | [] | no_license | enum Kingdom { Plant(u32, &'static str), Animal(u32, &'static str) }
fn main() {
let all_the_big_things = [
Kingdom::Plant(250, "redwood"),
Kingdom::Plant(230, "noble fir"),
Kingdom::Plant(229, "sugar pine"),
Kingdom::Animal(25, "blue whale"),
Kingdom::Animal(19, "fin whale"),
Kingdom::Animal... | true |
769e41899009af06bb9030a002bba66b92a8ff65 | Rust | samrg472/metrics | /metrics-runtime/src/data/counter.rs | UTF-8 | 494 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::common::ValueHandle;
/// Proxy object to update a counter.
pub struct Counter {
handle: ValueHandle,
}
impl Counter {
/// Records a value for the counter.
pub fn record(&self, value: u64) {
self.handle.update_counter(value);
}
/// Increments the counter by one.
pub fn incre... | true |
709d1688db3d46c05bfa02374d4788843392308e | Rust | therealprof/stm32f042 | /src/dma/ccr4/mod.rs | UTF-8 | 17,892 | 2.75 | 3 | [
"BSD-3-Clause",
"0BSD"
] | 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::CCR4 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... | true |
0bc040edc4bc4dfbb332f389593ee99568ca80e5 | Rust | Tricked-dev/workers-rs | /worker/src/global.rs | UTF-8 | 1,373 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use crate::{request::Request as WorkerRequest, response::Response as WorkerResponse, Result};
use worker_sys::{Response as EdgeResponse, WorkerGlobalScope};
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::JsFuture;
/// Construct a Fetch call from a URL string or a Request object. Call its `send` method to execute... | true |
2f0ff69cd2b4d5244e7ef1e7bf84b0238cff7184 | Rust | enso-org/enso | /lib/rust/ensogl/component/drop-manager/src/lib.rs | UTF-8 | 7,490 | 2.5625 | 3 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | //! The handlers for the files dropped on the web scene. The main object is [`Manager`]:
//! it notifies about new files, and their metadata and with methods for reading them.
// === Standard Linter Configuration ===
#![deny(non_ascii_idents)]
#![warn(unsafe_code)]
#![allow(clippy::bool_to_int_with_if)]
#![allow(clipp... | true |
593da87e1c02be28c5dca40439e2d0d03c4526f4 | Rust | kev-the-dev/weekends | /robotics/icansim/src/main.rs | UTF-8 | 1,782 | 3.5625 | 4 | [] | no_license | use std::time::{Duration, Instant};
use std::thread::sleep;
struct SimulationState {
startTime: Instant,
time: Instant,
}
impl Default for SimulationState {
fn default() -> Self {
let now = Instant::now();
Self{startTime: now, time: now}
}
}
trait Entity
{
fn update(&mut self, s... | true |
95403d0e325f27be161d76f3351953cd9f970e8d | Rust | weichweich/rust-workshop | /grepper/src/scan.rs | UTF-8 | 3,031 | 3.609375 | 4 | [] | no_license | use crate::manipulator::Manipulator;
use regex::Regex;
use std::fs::{DirEntry, File};
use std::io::{BufRead, BufReader};
pub trait Scan {
fn scan(self: &mut Self, file: &DirEntry);
}
pub struct RegexFilter<T: Manipulator> {
filter: Regex,
manipulator: T,
}
impl<T: Manipulator> Scan for RegexFilter<T> {
... | true |
c7e7dbabbe2ff6c488a2f223d43118a62e744442 | Rust | placrosse/tide-acme | /src/lib.rs | UTF-8 | 7,908 | 3.359375 | 3 | [] | no_license | //! `tide-acme` helps you serve HTTPS with Tide using automatic certificates, via Let's Encrypt and
//! ACME tls-alpn-01 challenges.
//!
//! To use `tide-acme`, set up HTTPS with Tide normally using `tide_rustls`, but instead of
//! specifying a certificate and key, call the `acme` method to configure automatic certifi... | true |
f30c7dc201059c97a8a20c3adffc4690819af4cb | Rust | tabnine/rust-echo-server | /src/main.rs | UTF-8 | 3,142 | 2.875 | 3 | [] | no_license | use anyhow::{Result, anyhow};
use std::{io, thread};
use std::net::{TcpListener, SocketAddr, SocketAddrV4, Ipv4Addr, TcpStream};
use socket2::{Socket, Domain, Type};
use std::io::{BufReader, Write, BufRead};
use structopt::StructOpt;
#[derive(StructOpt)]
#[structopt(name = "rust-echo-server")]
struct Opt {
#[struc... | true |
f95e308747c4c71f0f784007da9497fee60d2e18 | Rust | deltachat/lettre | /lettre_email/examples/local.rs | UTF-8 | 909 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate lettre;
extern crate lettre_email;
extern crate mime;
use lettre::{SmtpClient, Transport};
use lettre_email::Email;
use std::path::Path;
fn main() {
let email = Email::builder()
// Addresses can be specified by the tuple (email, alias)
.to(("user@example.org", "Firstname Lastname"))
... | true |
17bb819bba1f858e6327b0c294b13229bd0f9492 | Rust | taubeklavs/advent | /rust/src/y2020/d2.rs | UTF-8 | 2,657 | 3.0625 | 3 | [] | no_license | use regex::Regex;
use crate::helpers;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_parse_line() {
assert_eq!(
parse_line("1-3 a: abcde"),
Password {
arg_1: 1,
arg_2: 3,
symbol: 'a',
text: "abcde".to_... | true |
92b3792f4a36ddb56238146a80f62bdaf58efee7 | Rust | djanatyn/fend | /core/src/eval.rs | UTF-8 | 1,343 | 2.9375 | 3 | [
"MIT",
"GPL-3.0-only",
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::sync::Arc;
use crate::{
ast,
err::{IntErr, Interrupt},
lexer, parser,
scope::Scope,
value::Value,
};
pub fn evaluate_to_value<'a, I: Interrupt>(
input: &'a str,
scope: Option<Arc<Scope<'a>>>,
int: &I,
) -> Result<Value<'a>, IntErr<String, I>> {
let lex = lexer::lex(input, ... | true |
cec7dd590f95a8caaaa65d1c2f139606d2fd8a54 | Rust | Mackirac/numerical_methods | /matrix/src/vector.rs | UTF-8 | 3,731 | 3.484375 | 3 | [] | no_license | #[derive(Clone, PartialEq)]
pub struct Vector {
values: Box<[f64]>
}
impl Vector {
pub fn dimensions(&self) -> usize { self.values.len() }
pub fn new(dimensions: usize, formation: impl Fn(usize)->f64) -> Vector {
let mut values = Vec::with_capacity(dimensions);
for i in 0..dimensions {
... | true |
71ea8ad462b3942839508474399c4566666ab54b | Rust | haraldh/pfds | /src/hashset.rs | UTF-8 | 9,504 | 2.578125 | 3 | [
"BSD-3-Clause"
] | permissive | //
// Copyright 2021-Present (c) Raja Lehtihet & Wael El Oraiby
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditio... | true |
66d005a2d6fbdf4f16c6694f3b73fc0b1b6f0964 | Rust | WahyuSetiawan/rust_grpc | /src/service.rs | UTF-8 | 4,873 | 2.796875 | 3 | [] | no_license | use chrono::*;
use uuid::Uuid;
use mysql::prelude::*;
use crate::db_connection::establish_connection;
use tonic::{Request, Response, Status};
use crate::user::{
crud_server::Crud, CreateUserReply, CreateUserRequest, DeleteUserReply, Empty, UpdateUserReply,
UpdateUserRequest, UserReply, UserReques... | true |
815ecd4b71de57332613488b38e4f8bee13547b9 | Rust | gadunga/AdventOfCode2017 | /src/d8.rs | UTF-8 | 3,668 | 3.625 | 4 | [] | no_license | use std::collections::HashMap;
#[derive(Debug, Clone)]
enum Operator {
GT,
LT,
EQ,
GTEQ,
LTEQ,
NE,
}
#[derive(Debug, Clone)]
struct Instruction {
register: String,
increment: bool,
inc_val: i32,
op_reg: String,
op: Operator,
val: i32,
}
#[allow(dead_code)]
pub fn probl... | true |
563231d0bbfa2a486ced6df07f9f8be82a327d28 | Rust | bjornua/euler-rust | /src/euler/euler025.rs | UTF-8 | 613 | 3.25 | 3 | [] | no_license | use std::ops::Add;
use std::mem::replace;
use digits::{DigitsBuf};
struct Fibonacci {
a: DigitsBuf,
b: DigitsBuf
}
impl Iterator for Fibonacci {
type Item = DigitsBuf;
fn next(&mut self) -> Option<Self::Item> {
let c = self.a.add(&self.b);
let a = replace(&mut self.b, c);
let re... | true |
9858159589c356d80b51da91a6263c4b936253f1 | Rust | tanakh/simulated-annealing | /src/lib.rs | UTF-8 | 3,788 | 3.140625 | 3 | [
"MIT"
] | permissive | use rand::prelude::*;
use std::thread;
#[derive(Clone)]
pub struct AnnealingOptions {
pub steps: usize,
pub limit_temp: f64,
pub restart: usize,
pub threads: usize,
pub silent: bool,
}
pub trait Annealer {
type State: Clone + Send + Sync;
type Move;
fn init_state(&self, rng: &mut impl... | true |
4a2fd09e90817d2ac52d0b7c75a9671e63a08d24 | Rust | vickenty/rework | /rework/src/cmd.rs | UTF-8 | 1,760 | 3.078125 | 3 | [] | no_license | use std::{env, fs, io};
use std::io::{Read, Write};
use std::error::Error;
use docopt::Docopt;
use syntax::Elem;
use parser;
#[derive(Debug, Deserialize)]
struct Args {
arg_name: Vec<String>,
arg_output: Option<String>,
}
pub fn simple<F>(desc: &str, mut f: F)
where
F: FnMut(&mut Elem),
{
let name = e... | true |
95acff233856374c5a75be59aea730e5bb779681 | Rust | photon-garden/recreating-sainte-victoire-en-rond | /snapshots/2021-10-30 11:21:04/components/horizontal_strokes.rs | UTF-8 | 1,184 | 2.65625 | 3 | [] | no_license | use crate::prelude::*;
use rstar::*;
pub struct HorizontalStrokes {
points: Vec<Point2>,
boundary_rtree: RTree<My<Point2>>,
}
pub fn new(app: &App, container: &Rect) -> HorizontalStrokes {
let points = load_denormalized_points(app, container);
let my_points: Vec<My<Point2>> = points.iter().map(|point|... | true |
2305ef9beaa203cbe479fcff26e2ced4da459113 | Rust | LaplaceKorea/newton_rootfinder | /src/solver_n_dimensional/iteratives/iteratives_base.rs | UTF-8 | 5,571 | 3.015625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fmt;
/// Iterative definition
///
/// One might want to limit the update steps, by either:
/// - limiting the range of values to avoid non-sense values
/// - limiting the size of an update step
///
/// Two implementations of this trait are provided:
/// - `IterativeParams`
/// - `IterativeParamsFD`
pub trait ... | true |
9fa04dd8161a12da0da7e6dd5f7f286271a5c232 | Rust | reformat0r/nae | /examples/mask3.rs | UTF-8 | 1,094 | 2.984375 | 3 | [] | no_license | use nae::prelude::*;
struct State {
geom: Geometry,
rot: f32,
}
#[nae::main]
fn main() {
nae::init_with(init).draw(draw).build().unwrap();
}
fn init(_: &mut App) -> State {
let mut geom = Geometry::new();
for x in 0..10 {
for y in 0..10 {
geom.circle((x as f32) * 20.0 + 10.0, ... | true |
5530fdd151fb67e640d16fe4b2129b605a9337a7 | Rust | isgasho/Lystem | /src/main.rs | UTF-8 | 6,010 | 2.546875 | 3 | [] | no_license | // to render: ffmpeg -r 60 -y -i images/out%d.png output.mp4
// to resize: -vf scale=iw*2:ih*2 -sws_flags neighbor
// TODO:
// Invisible forward
// Draw point on turtle position
// Line widths (I think we havo to switch line drawing algorithm)
// Make the user choose the number of still frames at the end of the video ... | true |
558bc7cbc793a36d7afd83a65d49aa15d83b32a0 | Rust | Daru13/ens-reactrust | /src/signals/mod.rs | UTF-8 | 1,086 | 3.0625 | 3 | [
"MIT"
] | permissive | /// **The core of signals, used internally only.**
///
/// This sub-module contains all the data required by a signal to work,
/// as well as various methods used to interface a more abstract, actual signal, with
/// lower level mechanisms such as the runtime and continuations (see related modules for details).
///
///... | true |
89b868a10f39137b5ea233405aff6ba356e649d3 | Rust | matthewmichihara/advent-of-code | /2021/04/2.rs | UTF-8 | 2,098 | 3.25 | 3 | [] | no_license | fn main() {
let input = include_str!("input.txt");
let parts: Vec<&str> = input.split("\n\n").collect();
let nums: Vec<i32> = parts[0].split(",")
.map(|n| n.parse().expect("Could not parse number"))
.collect();
let cards: Vec<Vec<Vec<i32>>> = parts[1..].iter().map(|part| {
part.lines().map(|line| {... | true |
4f8625acf63ec8082ed84c776ce699c12824d9f9 | Rust | pierrechevalier83/unicode_types | /src/generated/gunjala_gondi.rs | UTF-8 | 10,257 | 3.59375 | 4 | [
"LicenseRef-scancode-unicode"
] | permissive |
/// An enum to represent all characters in the GunjalaGondi block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum GunjalaGondi {
/// \u{11d60}: '𑵠'
LetterA,
/// \u{11d61}: '𑵡'
LetterAa,
/// \u{11d62}: '𑵢'
LetterI,
/// \u{11d63}: '𑵣'
LetterIi,
/// \u{11d64}: '𑵤'
... | true |
fa9542f8e47358f471df08b8e3f03f398e8b2aca | Rust | maboesanman/AoC2020 | /day-6/src/main.rs | UTF-8 | 1,884 | 3.078125 | 3 | [] | no_license | use std::{collections::HashSet, fs::File, collections::HashMap};
use std::io::{prelude::*, BufReader};
fn _part_1() -> std::io::Result<()> {
let file = File::open("in")?;
let reader = BufReader::new(file);
let mut groups: Vec<HashSet<char>> = Vec::new();
let mut current_group: HashSet<char> = HashSet:... | true |
68af7b72a0174bd34c216b3954a20b7a879d5587 | Rust | CBenoit/advent-of-code | /2020/src/bin/7-1.rs | UTF-8 | 1,743 | 3.28125 | 3 | [] | no_license | use std::collections::HashMap;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let input = std::fs::read_to_string("inputs/7")?;
let rules: HashMap<&str, _> = input.lines()
.map(parse_line)
.collect();
let result = rules
.keys()
.filter(|container| can_contains(*cont... | true |
ea14f7c8eefea052e06ef433dc91f769abf811a0 | Rust | garlond/memscanner | /memscanner/src/signature/parser.rs | UTF-8 | 4,581 | 3.03125 | 3 | [
"BSD-3-Clause"
] | permissive | use nom::{
branch::alt,
bytes::complete::{tag, take},
character::complete::digit1,
combinator::{map_res, opt, recognize, value},
multi::many1,
sequence::pair,
IResult,
};
use super::{Match, Op};
#[rustfmt::skip]
fn match_signed_integer(input: &str) -> IResult<&str, &str> {
recognize(pa... | true |
2731c2ddcfc1273d4bb8ea5340044fce289038e1 | Rust | nanreh/strava-rs | /strava_rs/src/models/detailed_athlete_all_of.rs | UTF-8 | 2,812 | 2.6875 | 3 | [] | no_license | /*
* Strava API v3
*
* The [Swagger Playground](https://developers.strava.com/playground) is the easiest way to familiarize yourself with the Strava API by submitting HTTP requests and observing the responses before you write any client code. It will show what a response will look like with different endpoints depen... | true |
d062132ae35a724488735af3b53603b96e545e80 | Rust | pouya-gh/go_to_rust | /001_values.rs | UTF-8 | 338 | 3.3125 | 3 | [] | no_license | fn main() {
println!("{}", "a string".to_string()); // String
println!("this is an str"); // str
println!("{}", 3.14 * 6.45); // float (f64)
// rust's numeric types:
// i8, i16, i32, i64 (signed integer)
// u8, u16, u32, u64 (unsigned integer)
// isize, usize
// f32, f64 (float)
println!("{}", true ||... | true |
65bcc1120d2da91b3d092dc6fb9ed2a3425da413 | Rust | shaoxp/hello_rust | /closure/src/counter.rs | UTF-8 | 496 | 3.734375 | 4 | [
"MIT"
] | permissive | struct Counter {
count : u32,
}
impl Counter{
fn new() -> Counter{
Counter{count:0}
}
}
impl Iterator for Counter{
type Item = u32;
fn next(&mut self) -> Option<Self::Item>{
if self.count < 5{
self.count +=1;
Some(self.count)
}else{
None... | true |
d8a6b6a6d7c6ae7e4cd3571349b1ef2cd21f1a21 | Rust | arthurprs/rotor-stream | /src/transport.rs | UTF-8 | 1,340 | 2.90625 | 3 | [
"MIT"
] | permissive | use {Buf, Transport, StreamSocket};
impl<'a, S: StreamSocket> Transport<'a, S> {
/// Get the reference to the underlying stream
///
/// It's here so you can inspect socket state or tune it. For example you
/// might want to set TCP_CORK option or find out peer or local address.
///
/// Reading... | true |
67f96d52f25b8467437e14fb3e655edf0b198d1f | Rust | sannybuilder/GetObjectID | /src/lib.rs | UTF-8 | 3,477 | 2.59375 | 3 | [
"MIT"
] | permissive | use ctor::ctor;
use simplelog::*;
use std::{
ffi::{c_char, CString},
path::Path,
};
mod dir_walker;
fn pchar_to_str<'a>(s: *const c_char) -> Option<&'a str> {
if s.is_null() {
None
} else {
unsafe { Some(std::ffi::CStr::from_ptr(s).to_str().ok()?) }
}
}
fn get_path<'a>(path: *const... | true |
37e1b7a74ac2994aa2f2ecf882c9bad80649c781 | Rust | dam4rus/msoffice-shared-rs | /src/docprops.rs | UTF-8 | 2,919 | 2.75 | 3 | [
"MIT"
] | permissive | use crate::xml::XmlNode;
use std::{
io::{Read, Seek},
str::FromStr,
};
use zip::read::ZipFile;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
#[derive(Debug, Clone, PartialEq, Default)]
pub struct AppInfo {
pub app_name: Option<String>,
pub app_version: Option<String>,
}
impl Ap... | true |
4bb21a5af22e7c2d9b7f1a4f87973c5f17894b51 | Rust | ConnectedSystems/loop-lang-comparison | /Rust/loop.rs | UTF-8 | 233 | 2.59375 | 3 | [] | no_license | // Rust 1.4
// compiled with: rustc -O loop.rs
fn main() {
let a: u32 = 10;
let mut result: u32 = 1;
for n in 1..10000001 {
result = 1;
for i in 1..(a+1) {
result = result + (a - i) + n;
}
}
println!("{}", result);
} | true |
cfb6c2003041c6008296a507a8a314de4dee1b1a | Rust | astral-sh/ruff | /crates/ruff/src/rules/pylint/settings.rs | UTF-8 | 4,149 | 2.90625 | 3 | [
"BSD-3-Clause",
"0BSD",
"LicenseRef-scancode-free-unknown",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0"
] | permissive | //! Settings for the `pylint` plugin.
use anyhow::anyhow;
use ruff_python_ast::Constant;
use serde::{Deserialize, Serialize};
use ruff_macros::{CacheKey, CombineOptions, ConfigurationOptions};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, CacheKey)]
#[serde(deny_unknown_fields, rename_all = "ke... | true |
325ace1e534b6984587c472d5837efa70ac4b238 | Rust | jonasrichard/rust-playground | /buf-chain/src/main.rs | UTF-8 | 1,497 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | use bytes::{Buf, BufMut, Bytes, BytesMut};
fn chain_with_slices() {
let mut main = BytesMut::with_capacity(256);
let params = Bytes::from(&b"parameters"[..]);
let len = params.len() as u32;
let length = [(len >> 24) as u8, (len >> 16) as u8, (len >> 8) as u8, len as u8];
let total = (&b"\x00HEAD"... | true |
2a72664df6eafad4150be7f8b42d93bfa7c3eb75 | Rust | asurance/rust-rasterization | /src/render_object.rs | UTF-8 | 1,515 | 2.8125 | 3 | [] | no_license | use crate::texture::Texture;
use crate::util::s_function;
pub struct RenderObject<'a> {
positions: [(f64, f64); 3],
zs: [f64; 3],
uvs: [(f64, f64); 3],
texture: &'a Texture,
sabc: f64,
ratio0: f64,
ratio1: f64,
ratio2: f64,
}
impl<'a> RenderObject<'a> {
pub fn new(
position... | true |
2feb251b94bef66cf6e928ed88fd464e86c799b3 | Rust | GuilloteauQ/tex-rs | /examples/cover_letter.rs | UTF-8 | 2,331 | 2.890625 | 3 | [] | no_license | extern crate tex_rs;
use std::io;
use tex_rs::core::*;
use tex_rs::latex_file::*;
use tex_rs::writable::Writable;
fn main() {
let mut variables = vec![
String::new(),
String::new(),
String::new(),
String::new(),
String::new(),
];
let queries = vec![
"national... | true |
c633250ea4dbf1d51e9b570b00ba4d94a89f2cfd | Rust | 1Crazymoney/wasmtime | /cranelift/frontend/src/variable.rs | UTF-8 | 958 | 3.515625 | 4 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | //! A basic `Variable` implementation.
//!
//! Frontends can use any indexing scheme they see fit and
//! generate the appropriate `Variable` instances.
//!
//! Note: The `Variable` is used by Cranelift to index into densely allocated
//! arrays containing information about your mutable variables
//! Thus, make sure th... | true |
638cb3571ff11a747a92d6a9961aa7b0e04fc14a | Rust | dillonhicks/holodeck | /crates/holodeck-viewer/src/world/shell.rs | UTF-8 | 2,097 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use crate::{
deps::{
kiss3d::{
resource::{
Mesh,
MeshManager,
},
window::Window,
},
na::{
Point3,
Translation3,
Vector3,
},
},
engine::GraphicsNode,
theme::Color,
w... | true |
7911796c7f294af5108438e538f0f60579eb6dbd | Rust | HevanHull/Rust | /chapter6/sub6.2/bind_value/src/main.rs | UTF-8 | 581 | 3.4375 | 3 | [] | no_license | #[derive(Debug)]
fn main() {
enum Province{
Ontario,
Quebec,
Alberta,
British Columbia
}
enum Coin{
Nickel,
Dime,
Quarter,
Loonie,
Toonie
}
fn Value_in_cents (coin: Coin) -> f32 {
match coin{
Coin::Nickel ... | true |
c153d59d86478198db58a36ce450331747784950 | Rust | tmokenc/tomoka-rs | /src/commands/music/radio.rs | UTF-8 | 3,687 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::commands::prelude::*;
use crate::types::{Music, Playable, PlayingInfo, PlayingSignal};
use crate::Result;
use serde::{Deserialize, Serialize};
use serenity::model::id::UserId;
use serenity::voice::{ffmpeg, AudioSource, Bitrate};
use std::env;
use std::fs;
use std::io::BufReader;
use std::io::{Error as IoErro... | true |
c377eedf46cb2f9ee1738b58dccdd7b3aee0e1fa | Rust | smacker/standup-rs | /src/report.rs | UTF-8 | 540 | 3.203125 | 3 | [] | no_license | use std::fmt;
#[derive(Clone)]
pub struct Entry {
pub r#type: String,
pub title: String,
pub url: Option<String>,
pub actions: Vec<String>,
}
impl fmt::Display for Entry {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let blank = "".to_string();
let url = self.url.as_ref()... | true |
c530dfc43fe9d1ef212e3283f14adafcbe23e3e1 | Rust | SergeevPavel/adventofcode2019 | /src/day17.rs | UTF-8 | 1,403 | 3.21875 | 3 | [] | no_license | mod computer;
use computer::*;
use std::convert::TryInto;
use std::collections::HashMap;
fn solve1(field: HashMap<(i64, i64), char>) {
let mut result = 0;
for (&(x, y), &ch) in &field {
if ch == '#' {
let neighbours_count = [(x + 1, y), (x, y + 1), (x - 1, y), (x, y - 1)].iter()
... | true |
202c3d64ab090371b000d584d0e5e900bf499b4a | Rust | srinikhil-07/Algorithmic-Problems-In-Rust-And-Swift | /october_2020/src/solutions/rotate_array.rs | UTF-8 | 854 | 2.984375 | 3 | [
"MIT"
] | permissive | impl crate::solutions::Solution {
#[warn(dead_code)]
///right-rotate, for left rotate reverse the reversings!
pub fn rotate(nums: &mut Vec<i32>, k: i32) {
if nums.len() == 0 || nums.len() == 1 {
return;
}
let d = k % (nums.len() as i32);
crate::solutions::Solution... | true |
f68a80f56ee96f9764bbbf048987a806b211474f | Rust | Amanieu/intrusive-rs | /src/unchecked_option.rs | UTF-8 | 1,048 | 2.859375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2020 Amari Robinson
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to tho... | true |
0eb3e0a29d3c390e73ed614315bcfa948b866e8f | Rust | valarauca/dice_backend | /dice_backend/src/peephole/graphs/remove_sink.rs | UTF-8 | 634 | 2.796875 | 3 | [] | no_license | use super::traits::{Graph, ModifyGraph};
use super::Match;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct RemoveSink {
from: Match,
sink: Match,
}
impl RemoveSink {
#[inline(always)]
pub fn new<A, B>(from: A, sink: B) -> Self
where
Match: From<A>,
Mat... | true |
656e04b0f523b35f1d9cbd6deb41d70cfd612371 | Rust | system-pclub/rust-study | /section-5-memory-safety-issues/reproduced-bugs/cve/CVE-2018-1000810/src/main.rs | UTF-8 | 3,372 | 2.8125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | extern crate core;
use core::ptr;
use std::time::Instant;
#[allow(dead_code)]
fn bug() {
// let n : usize = usize::max_value();
let a = b"0123456789abcdef";
let n: usize = 1 << 63;
// let a = b"012345";
/**
* I construct a and n in this way. let's take a look at what is the overflowed a.len * n
* look lik... | true |
6cee425175f55ec09c277b43ca59c0596201dc1c | Rust | 12101111/fbterm | /src/font/mod.rs | UTF-8 | 1,273 | 2.703125 | 3 | [
"MIT"
] | permissive | #[cfg(feature = "alloc")]
pub(crate) mod truetype;
pub(crate) mod vga;
#[cfg(feature = "alloc")]
use alloc::sync::Arc;
use core::ops::Deref;
pub enum Point {
Bit(bool),
Coverage(u8),
}
pub trait Font {
fn height(&self) -> usize;
fn get_glyph(&mut self, c: char) -> Option<Glyph>;
fn metrics(&self... | true |
8473f44def631d6b1b05fb5c9e6c8a2f79569c21 | Rust | richardanaya/string_concat | /src/lib.rs | UTF-8 | 1,349 | 3.078125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![no_std]
extern crate alloc;
#[doc(hidden)]
pub use alloc::string::String;
#[macro_export]
macro_rules! string_concat {
( $( $x:expr ),* ) => {{
$crate::string_concat_impl!{[] $($x),*}
}};
}
#[doc(hidden)]
#[macro_export]
macro_rules! string_concat_impl {
([$($x:ident)*] ) => {{
let mu... | true |
831a0d2a212eefba3965267661ac3ddbb641518c | Rust | dora-gt/tower-web | /src/extract/option.rs | UTF-8 | 1,125 | 3.21875 | 3 | [
"MIT"
] | permissive | //! Types used to extract `Option` values from an HTTP request.
use crate::extract::{Extract, ExtractFuture, Error, Context};
use crate::util::BufStream;
use futures::{Async, Poll};
/// Extract an `Option` value from an HTTP request.
#[derive(Debug)]
pub struct ExtractOptionFuture<T> {
inner: T,
none: bool,
... | true |
fcf2945c38c30fab00308d633dd97ca4f9cd7170 | Rust | rust-lang/rust-analyzer | /crates/ide-assists/src/handlers/convert_match_to_let_else.rs | UTF-8 | 11,208 | 2.671875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use ide_db::defs::{Definition, NameRefClass};
use syntax::{
ast::{self, HasName, Name},
ted, AstNode, SyntaxNode,
};
use crate::{
assist_context::{AssistContext, Assists},
AssistId, AssistKind,
};
// Assist: convert_match_to_let_else
//
// Converts let statement with match initializer to let-else stat... | true |
06ea47e6fd002844dacfbcddfe687ad3bcfd37b6 | Rust | fredlim/canvas | /packages/canvas/src-native/canvas-native/canvas-core/src/common/context/image_asset.rs | UTF-8 | 11,530 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use std::ffi::{CStr, CString};
use std::io::{Read, Seek, SeekFrom};
use std::os::raw::{c_char, c_uint};
use std::ptr::{null, null_mut};
use image::{GenericImageView, ImageFormat};
use image::imageops::FilterType;
use crate::common::ffi::u8_array::U8Array;
pub struct ImageAsset {
pub(crate) image: Option<image::D... | true |
87b214d0f0c6c37520e5f40a14012025200cde47 | Rust | human9/life | /src/core/window.rs | UTF-8 | 1,452 | 2.875 | 3 | [] | no_license | extern crate glium;
pub struct Window {
display: glium::Display,
pub events_loop: glium::glutin::EventsLoop,
}
impl Window {
pub fn new() -> Window {
let events_loop = glium::glutin::EventsLoop::new();
let window = glium::glutin::WindowBuilder::new()
.with_dimensions(800, 600... | true |
0e5fbf5bcf9a8591796f70a76cdfca5238eae6c5 | Rust | Canop/broot | /src/pattern/tok_pattern.rs | UTF-8 | 7,821 | 2.890625 | 3 | [
"MIT"
] | permissive | use {
super::NameMatch,
secular,
smallvec::{smallvec, SmallVec},
std::{
cmp::Reverse,
ops::Range,
},
};
type CandChars = SmallVec<[char; 32]>;
static SEPARATORS: &[char] = &[',', ';'];
// weights used in match score computing
const BONUS_MATCH: i32 = 50_000;
const BONUS_CANDIDATE_... | true |
01dddc8f4aaa859b5fb04db7f5b5c5b3b48dd995 | Rust | Virviil/aoc2018 | /src/guards/entry.rs | UTF-8 | 2,406 | 3.421875 | 3 | [] | no_license | use std::{fmt, error};
use std::str::FromStr;
use chrono::prelude::*;
use super::State;
#[derive(Debug)]
pub struct ParseEntryError;
impl fmt::Display for ParseEntryError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "invalid input string")
}
}
impl error::Error for ParseEntryErr... | true |
7c898321bd8b8c4e7622546a5a432ea6570db900 | Rust | thejpster/monotron-synth | /src/lib.rs | UTF-8 | 16,668 | 3.15625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![no_std]
pub const MAX_VOLUME: u8 = 255;
/// We have a three channel synthesiser.
#[derive(Debug, Copy, Clone)]
pub enum Channel {
Channel0,
Channel1,
Channel2,
}
pub const CHANNEL_0: Channel = Channel::Channel0;
pub const CHANNEL_1: Channel = Channel::Channel1;
pub const CHANNEL_2: Channel = Channel::... | true |
2484a9138da1ab8dd54dd0d58fda466470a26c45 | Rust | plzhang4321/os_summer | /LearningRust/src/sword_10_frog.rs | UTF-8 | 469 | 3.15625 | 3 | [] | no_license | impl Solution {
pub fn num_ways(n: i32) -> i32 {
if n < 2 {
return 1;
}
let (mut a, mut b) = (1, 1);
for _ in 2..=n {
let temp = (a + b) % 1000000007;
a = b;
b = temp;
}
b
}
}
//python3
//class Solution:
// def ... | true |
f13b7a32452ad246a9d42bbe3da208fdb6f76a02 | Rust | Alexendoo/Advent-of-Code-2020 | /day-02/src/main.rs | UTF-8 | 1,609 | 3.234375 | 3 | [] | no_license | use regex::Regex;
#[derive(Debug)]
struct Policy {
min: usize,
max: usize,
ch: char,
password: &'static str,
}
fn parse(line: &'static str, pattern: &Regex) -> Policy {
let captures = pattern.captures(line).unwrap();
let min: usize = captures[1].parse().unwrap();
let max: usize = captures... | true |
dd9e9506e3a637d4415d9a4491ccf197d290e976 | Rust | analogrelay/rignalrar | /src/error.rs | UTF-8 | 528 | 2.765625 | 3 | [] | no_license | #[derive(Debug)]
pub enum Error {
HttpError(hyper::Error),
IoError(String),
DeserializationError(serde_json::error::Error),
}
impl From<hyper::Error> for Error {
fn from(e: hyper::Error) -> Error {
Error::HttpError(e)
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error)... | true |
424713ee69009922c0965113c4979bb9e77a1109 | Rust | Windfisch/usb-device | /src/lib.rs | UTF-8 | 9,608 | 3.25 | 3 | [
"MIT"
] | permissive | //! Experimental device-side USB stack for embedded devices.
//!
//! ## Implementing a USB device
//!
//! A USB device consists of a [`UsbDevice`](device::UsbDevice) instance, one or more
//! [`UsbClass`](crate::class::UsbClass)es, and a platform-specific [`UsbBus`](bus::UsbBus)
//! implementation which together form a... | true |
9ab68398ff382246aaa25f016796c52a198b4eda | Rust | yoo2001818/rust-8086 | /src/i8086/operand.rs | UTF-8 | 3,686 | 3.234375 | 3 | [] | no_license | use std::ops::*;
use super::cpu::CPU;
use super::register::*;
use crate::mem::*;
#[derive(PartialEq, Copy, Clone)]
#[derive(Debug)]
pub enum AddressType {
BxSi,
BxDi,
BpSi,
BpDi,
Si,
Di,
Bp,
Bx,
}
#[derive(PartialEq)]
#[derive(Debug)]
pub enum Operand<T: RegisterType> {
Register(T),
Address(Addres... | true |
896f1f4cb127563f3d0830f5e7b77becea467e95 | Rust | azriel91/autexousious | /crate/asset_model/src/loaded/item_id.rs | UTF-8 | 500 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use amethyst::ecs::{
storage::{FlaggedStorage, VecStorage},
Component, Entity,
};
use derive_new::new;
/// ID of an item in the [`AssetWorld`].
///
/// An item is a "whole" object, so all item components associated with this item ID should be used
/// when spawning an entity in the game `World`.
#[derive(Clone... | true |
2754e7814a706be11cb40708e5e316d15f18e6c9 | Rust | timodw/AoC20 | /day_4/day_4_b.rs | UTF-8 | 4,643 | 3.21875 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use std::collections::HashSet;
const INPUT_NAME: &str = "input_4.txt";
fn read_input_file() -> String {
let path = Path::new(INPUT_NAME);
let display = path.display();
let mut file = match File::open(&path) {
Err(why) => panic!("Cou... | true |
43ab866fc9fa874b20b44c977d8bd66cc35d1b8c | Rust | gnoliyil/fuchsia | /third_party/rust_crates/vendor/scanlex-0.1.4/src/token.rs | UTF-8 | 5,818 | 3.578125 | 4 | [
"BSD-2-Clause",
"MIT"
] | permissive | use error::ScanError;
use int::Int;
/// Represents a token returned by `Scanner::get`
#[derive(Debug)]
#[derive(PartialEq)]
pub enum Token {
/// a floating-point number, stored as double-precision float
Num(f64),
/// an integer, stored as eight-byte unsigned
Int(i64),
/// a quoted string
Str(String),
///... | true |
f66aa17dcea75a97150551d030e137e5ddd8d6c5 | Rust | oshunter/fuchsia | /third_party/rust_crates/vendor/tokio/src/sync/tests/loom_mpsc.rs | UTF-8 | 1,638 | 2.609375 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | use crate::sync::mpsc;
use futures::future::poll_fn;
use loom::future::block_on;
use loom::thread;
#[test]
fn closing_tx() {
loom::model(|| {
let (mut tx, mut rx) = mpsc::channel(16);
thread::spawn(move || {
tx.try_send(()).unwrap();
drop(tx);
});
let v = ... | true |
ac75bfbd9298877112fe799a34df30f358f2de29 | Rust | leogtzr/rustlearning | /lifetime_annotations_in_struct_definitions/src/main.rs | UTF-8 | 1,000 | 3.34375 | 3 | [] | no_license | use std::fmt::Display;
#[derive(Debug)]
struct ImportantExcerpt<'a> {
part: &'a str,
}
impl<'a> ImportantExcerpt<'a> {
fn level(&self) -> i32 {
3
}
}
impl<'a> ImportantExcerpt<'a> {
fn announce_and_return_part(&self, announcement: &str) -> &str {
println!("Attention please: {}", announcement);
self.part ... | true |
2e681b1191236e8d5fcbd866e13f55867ce52710 | Rust | Wattyyy/LeetCode | /submissions/perfect-squares/solution.rs | UTF-8 | 513 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::cmp::min;
impl Solution {
pub fn num_squares(n: i32) -> i32 {
let mut dp = vec![10001; 10001];
for i in 0..101 {
dp[i * i] = 1;
}
for i in 1..((n + 1) as usize) {
for j in 1..101 {
let k = j * j;
if k < i {
... | true |
bc5597dc5bcc60de7ad4c2d01d2d45c3da7ac4cf | Rust | kuviman/ugli | /src/program.rs | UTF-8 | 2,976 | 2.796875 | 3 | [
"MIT"
] | permissive | use super::*;
pub struct Program {
pub(crate) ugli: Rc<Ugli>,
pub(crate) handle: raw::Program,
pub(crate) attributes: HashMap<String, AttributeInfo>,
pub(crate) uniforms: HashMap<String, UniformInfo>,
phantom_data: PhantomData<*mut ()>,
}
#[derive(Debug)]
pub struct AttributeInfo {
pub(crate) ... | true |
dc2061786b0b001804e4bb836f7935b829ba69da | Rust | wotsushi/competitive-programming | /etc/jsc2019-qual/d.rs | UTF-8 | 1,054 | 2.953125 | 3 | [
"MIT"
] | permissive | #![allow(non_snake_case)]
#![allow(unused_variables)]
fn main() {
let N: usize = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse().unwrap()
};
// 部屋をできる限り二等分し、それらの間を結ぶ通路は同レベルとする
// これを再帰的に繰り返す
fn f(level: i64, L: usi... | true |
ead1d12d6cc6ffc82261d77a1c1e9c818df059e8 | Rust | berleon/libtrees | /src/libtrees/utils.rs | UTF-8 | 1,629 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | /* Copyright 2013 Leon Sixt
*
* 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 agreed to in wr... | true |
1a355a5af0a1ebd1933b7f15dea8f3cb9d1f194f | Rust | johnyenter-briars/gentle_intro_to_rust | /threads_networking_filesharing/client_echo.rs | UTF-8 | 429 | 3.09375 | 3 | [] | no_license | use std::io::prelude::*;
use std::net::TcpStream;
fn main() {
let mut stream = TcpStream::connect("127.0.0.1:8000").expect("connection failed!");
let msg = "hello from client!";
write!(stream, "{}\n", msg).expect("write failed!");
let mut response = String::new();
stream.read_to_string(&mut response).expect(... | true |
9a9fa036a84da7a124d7884364d91ac73ecf72be | Rust | gvvynplaine/bottom | /src/data_conversion.rs | UTF-8 | 37,573 | 2.546875 | 3 | [
"MIT"
] | permissive | //! This mainly concerns converting collected data into things that the canvas
//! can actually handle.
use crate::Pid;
use crate::{
app::{data_farmer, data_harvester, App, Filter, ProcWidgetState},
utils::{self, gen_util::*},
};
use data_harvester::processes::ProcessSorting;
use indexmap::IndexSet;
use std::co... | true |
8b0905cf36e2e5fd190f9a6d33ae2450a143ce84 | Rust | aweinstock314/power | /examples/rayon_test.rs | UTF-8 | 2,413 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | #![allow(dead_code)]
#![feature(test)]
extern crate futures;
extern crate rayon;
extern crate tokio_core;
extern crate test;
use futures::{Future, Stream, Sink};
use rayon::iter::ParallelIterator;
use rayon::iter::IntoParallelIterator;
fn expensive_work() -> u64 {
(0..(0u64).wrapping_sub(1)).into_par_iter().reduc... | true |
f7a874f7a95a8ebf062a5b0e482893146abcaef4 | Rust | lucaspoffo/netcarrier | /demo/src/lib.rs | UTF-8 | 3,556 | 3.03125 | 3 | [] | no_license | use netcarrier::generate_packet;
use rand::Rng;
use serde::{Deserialize, Serialize};
use netcarrier::Delta;
#[derive(Debug, Serialize, Deserialize, Copy, Clone, PartialEq)]
pub struct Color(pub [f32; 4]);
impl Color {
pub fn random() -> Self {
let mut rng = rand::thread_rng();
Color([
... | true |
29d0ff17b872c0897d3148f47ca9d0d57d9a440f | Rust | claderoki/Intergalactica-Discord-Bot-Rust | /src/modules/conversion/data_controller.rs | UTF-8 | 2,746 | 2.75 | 3 | [] | no_license | use std::{collections::HashMap, fs::File, io::BufReader};
use once_cell::sync::Lazy;
use super::{
models::{currency::Currency},
repository::{currency_repository::CurrencyRepository, measurement_repository::NewMeasurement},
};
pub static CONFIG: Lazy<HashMap<String, bool>> = Lazy::new(|| {
let m = Has... | true |
e445c4b308b3e65c06abcf20b91be0bcdb16c46a | Rust | iqlusioninc/abscissa | /core/src/component.rs | UTF-8 | 3,826 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | //! Application components: extensions/plugins for Abscissa applications.
//!
//! See docs on the `Component` trait for more information.
#![allow(unused_variables)]
mod handle;
mod id;
pub mod registry;
pub use self::{handle::Handle, id::Id, registry::Registry};
pub use abscissa_derive::Component;
use crate::{appl... | true |
b44e218f29243b96eb9e1d55b587d2fe01d4abf9 | Rust | bevyengine/bevy | /crates/bevy_reflect/bevy_reflect_derive/src/derive_data.rs | UTF-8 | 31,821 | 2.65625 | 3 | [
"Apache-2.0",
"MIT",
"Zlib",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive"
] | permissive | use crate::container_attributes::{FromReflectAttrs, ReflectTraits};
use crate::field_attributes::{parse_field_attrs, ReflectFieldAttr};
use crate::type_path::parse_path_no_leading_colon;
use crate::utility::{members_to_serialization_denylist, StringExpr, WhereClauseOptions};
use bit_set::BitSet;
use quote::{quote, ToTo... | true |
b87f278bb35bf6802373b95a4cf54b36c14a2c3f | Rust | csmartin6/project-euler-rust | /problems/src/problem_009.rs | UTF-8 | 583 | 3.0625 | 3 | [] | no_license | pub fn problem_009() -> u64 {
let n = 1000;
for i in 0..n {
for j in i..((n - 1) / 2) {
let k = n - i - j;
if i * i + j * j == k * k {
return i * j * k;
}
}
}
0
}
#[cfg(test)]
mod test {
use super::*;
use test::Bencher;
... | true |
a899c95268d024271e89f7053bd7c1226e283486 | Rust | vi/dyn_safe.rs | /src/proc_macros/utils.rs | UTF-8 | 2,517 | 2.671875 | 3 | [
"Zlib",
"Apache-2.0",
"MIT"
] | permissive | /// mini-`syn`
macro_rules! unwrap_next_token {(
if let $($pat:pat)|+ = $mb_token:expr,
$(if ($($guard:tt)*))?
$expr:block
else {
failwith!($err_msg:expr $(, $($($rest:tt)+)?)? );
}
) => (
match $mb_token {
$( | Some($pat) )+
$(if $($guard)*)?
=> $expr,
... | true |
82282ce548b7b40d2c844942c3027155477254a9 | Rust | 0xb10ckdev/forest | /src/utils/db/car_index/key_value_pair.rs | UTF-8 | 651 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2019-2023 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use super::Hash;
pub type FrameOffset = u64;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(test, derive(derive_quickcheck_arbitrary::Arbitrary))]
pub struct KeyValuePair {
pub hash: Hash,
pub value: FrameOffset,
}
... | true |
3a7ab490047d25d5f45d254b553524067261f499 | Rust | kjp4155/rust-aoc | /day1/src/main.rs | UTF-8 | 925 | 3.015625 | 3 | [] | no_license | use std::io;
fn solve(v: &[i32], i: usize, j: usize, count: u32, target_sum: i32) -> i32 {
if count == 0 {
if target_sum == 0 { 1 } else { 0 }
}
else {
for idx in i..j {
if v[idx] <= target_sum {
let partial_mul = solve(&v, idx + 1, j, count - 1, target_sum - v[i... | true |
b7f789f190ffdacde863014c7bb132057d6e7b1b | Rust | AndrewSisley/CQLDb | /cql_storage_types/cql_nullable_f64/src/nullable_f64.rs | UTF-8 | 7,553 | 2.96875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | /*!
This crate implements various [CqlType](https://docs.rs/cql_model/0.2/cql_model/trait.CqlType.html) derivatives for storing `Option<f64>` values in a CQL database.
Will allocate 9 bytes per value [linked](https://docs.rs/cql_db/0.2/cql_db/fn.link_dimensions.html).
# Benchmarks
Benchmarks supplied below are ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.