Rust
E0615 Take Value of Method Fix
A method is not a field. Writing the name after a dot, with no parentheses, tries to take the method itself as a value — and Rust refuses, in an assignment, in an argument, and in the middle of an iterator chain alike. Add the parentheses and the same line calls the method and produces the value the code wanted.
Written November 26, 2026 · Tested with Rust 1.99.1 · 16 min read
- The error: a standard library method used with no call
- A method on your own struct fails the same way
- The same access passed as an argument
- Iterator and trait methods fail the same way
Written November 26, 2026
Tested with Rust 1.99.1
What this guide is
This error is a missing pair of parentheses, and the compiler says so in its second line: the name after the dot is a method, not a field. A field access — a value, a dot, and an identifier — evaluates to the location of a field of a struct. A method call is a different expression: a receiver, a dot, a name, and a parenthesized list of arguments, even when that list is empty. Writing only the first half of a method call leaves an expression that tries to take the method itself as a value, and there is no such value to take in that form.
That is why the fix is the same in every shape below. The shapes differ only in where the half-written call sits: in an assignment, on a type you defined yourself, inside a function call's argument list, at the start of an iterator chain, or on a method that comes from a trait rather than from the type itself. None of them needs a different repair, a conversion, or a workaround — each one needs the call to be finished. The one place where a method really can be taken as a value is covered at the end, and it does not use dot access at all: it names the method by its full path.
The error: a standard library method used with no call
len is a method, not a field. A String has private fields, and its length — in bytes, not characters — is returned by calling len() on the str it dereferences to. This program leaves the parentheses off:
// broken.rs
fn main() {
let text = String::from("hello");
let n = text.len;
println!("{n}");
}
$ rustc --edition 2021 broken.rs -o broken.bin
error[E0615]: attempted to take value of method `len` on type `String`
--> broken.rs:3:18
|
3 | let n = text.len;
| ^^^ method, not a field
|
help: use parentheses to call the method
|
3 | let n = text.len();
| ++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0615`.
Read the two annotations, because together they are the whole diagnosis. The caret line says method, not a field: the compiler found the name, and the name belongs to a method. The help line then gives the repair in full — use parentheses to call the method — and shows the corrected line with the ++ marking exactly what to add. Nothing else in the program is wrong.
The fix is that line:
// fixed_len.rs
fn main() {
let text = String::from("hello");
let n = text.len();
println!("{n}");
}
$ rustc --edition 2021 fixed_len.rs -o fixed_len.bin
$ ./fixed_len.bin
5
The program prints 5 and exits with status 0. The value the assignment wanted was never the method; it was the result of calling the method, and the parentheses are what make the call happen.
A method on your own struct fails the same way
Nothing about this error is specific to the standard library. A method defined in an impl block on your own type is a method in exactly the same sense, and leaving its parentheses off produces the same code, with your type and your method named in the message:
// custom.rs
struct Counter {
count: u32,
}
impl Counter {
fn total(&self) -> u32 {
self.count
}
}
fn main() {
let counter = Counter { count: 7 };
let n = counter.total;
println!("{n}");
}
$ rustc --edition 2021 custom.rs -o custom.bin
error[E0615]: attempted to take value of method `total` on type `Counter`
--> custom.rs:13:21
|
13 | let n = counter.total;
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
13 | let n = counter.total();
| ++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0615`.
Note what the error is not. The struct does have a field, count, and counter.count would be a valid field access that returns 7 by a different route. The line as written names total, which exists only as a method, so the compiler reports the method it found rather than guessing at the field. If the name you wrote was meant to be a field, the official guidance for this code is to check that the field name is spelled correctly; if it was meant to be the method, the repair is the call:
// custom_fixed.rs
struct Counter {
count: u32,
}
impl Counter {
fn total(&self) -> u32 {
self.count
}
}
fn main() {
let counter = Counter { count: 7 };
let n = counter.total();
println!("{n}");
}
$ rustc --edition 2021 custom_fixed.rs -o custom_fixed.bin
$ ./custom_fixed.bin
7
The program prints 7 and exits with status 0 — the value total() computes from the field, reached by calling the method rather than by reading the field directly.
The same access passed as an argument
The position of the half-written call does not matter. Inside an argument list, where a usize value is expected, text.len is still an attempt to take the method as a value, and it fails before any question of argument types arises:
// passed_arg.rs
fn show(n: usize) {
println!("{n}");
}
fn main() {
let text = String::from("hello");
show(text.len);
}
$ rustc --edition 2021 passed_arg.rs -o passed_arg.bin
error[E0615]: attempted to take value of method `len` on type `String`
--> passed_arg.rs:7:15
|
7 | show(text.len);
| ^^^ method, not a field
|
help: use parentheses to call the method
|
7 | show(text.len());
| ++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0615`.
This shape is the one that misleads, because the expected type is sitting right there in the function signature and the error never mentions it. There is no type mismatch to fix: the argument expression itself does not produce a value at all. Storing the access in a variable first changes nothing — the assignment form in the first section is that same attempt, one line earlier. Finish the call, and the argument is the usize the function asked for:
// passed_arg_fixed.rs
fn show(n: usize) {
println!("{n}");
}
fn main() {
let text = String::from("hello");
show(text.len());
}
$ rustc --edition 2021 passed_arg_fixed.rs -o passed_arg_fixed.bin
$ ./passed_arg_fixed.bin
5
The program prints 5 and exits with status 0.
Iterator and trait methods fail the same way
Methods that start or continue a chain are methods too. iter is looked up the same way as any other method — a type's inherent methods are searched first, then the methods provided by visible traits it implements — and writing it without parentheses stops the chain before it starts:
// iter.rs
fn main() {
let numbers = vec![10, 20, 30];
let it = numbers.iter;
println!("{}", it.count());
}
$ rustc --edition 2021 iter.rs -o iter.bin
error[E0615]: attempted to take value of method `iter` on type `Vec<{integer}>`
--> iter.rs:3:22
|
3 | let it = numbers.iter;
| ^^^^ method, not a field
|
help: use parentheses to call the method
|
3 | let it = numbers.iter();
| ++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0615`.
// iter_fixed.rs
fn main() {
let numbers = vec![10, 20, 30];
let it = numbers.iter();
println!("{}", it.count());
}
$ rustc --edition 2021 iter_fixed.rs -o iter_fixed.bin
$ ./iter_fixed.bin
3
The fixed program prints 3 and exits with status 0: iter() produces the iterator, and count() — also called, with its own parentheses — consumes it. An adapter in the middle of a chain behaves identically. In a program that writes numbers.iter().map with no call after map, the compiler reports E0615 for the method map on the iterator type, and its help suggests map(_) — the adapter still has to be called, with its closure argument supplied.
A method that comes from a trait is no different. to_string is the required method of the ToString trait, which is automatically implemented for any type that implements Display; an integer gets it from that trait, not from an inherent implementation. Leaving its parentheses off names the trait method as a value, and the same error follows:
// trait_method.rs
fn main() {
let n = 42;
let s = n.to_string;
println!("{s}");
}
$ rustc --edition 2021 trait_method.rs -o trait_method.bin
error[E0615]: attempted to take value of method `to_string` on type `{integer}`
--> trait_method.rs:3:15
|
3 | let s = n.to_string;
| ^^^^^^^^^ method, not a field
|
help: use parentheses to call the method
|
3 | let s = n.to_string();
| ++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0615`.
// trait_fixed.rs
fn main() {
let n = 42;
let s = n.to_string();
println!("{s}");
}
$ rustc --edition 2021 trait_fixed.rs -o trait_fixed.bin
$ ./trait_fixed.bin
42
The fixed program prints 42 and exits with status 0.
The legitimate counterpart: a method taken as a value by its full path
There is one form in which a method really is a value, and it is the form to reach for when the intent was never to call the method on one receiver, but to hand the method itself to something that will call it on many receivers. Name the method by its full path — type, ::, method name, with no receiver and no dot — and it can be passed where a function is expected. Function pointers can be created by coercion from function items, and a method named this way is used the same way here: map receives String::len and calls it on each string in turn:
// path_value.rs
fn main() {
let words = vec![String::from("a"), String::from("hello")];
let lens: Vec<usize> = words.iter().map(String::len).collect();
println!("{:?}", lens);
}
$ rustc --edition 2021 path_value.rs -o path_value.bin
$ ./path_value.bin
[1, 5]
The program prints [1, 5] and exits with status 0 — the lengths of the two strings, produced by the method that the dot form refused to hand over. The same form works for other types: groups.iter().map(Vec::len), over a vector of vectors, compiles, runs, and prints [2, 3]. The distinction the compiler is enforcing is therefore not "methods can never be values." It is that a method is taken as a value by naming it as an item, with its full path — never by writing it after a receiver and a dot, which is field-access syntax, and a method is not a field.
A neighboring case: Vec::len without parentheses is a different error
One common version of this mistake reports a different code, and the difference is informative rather than contradictory. A Vec really does store its length in a field of the same name — a private one. So on a Vec, the dot access finds a field first, and the error is about that field:
// vec_len.rs
fn main() {
let numbers = vec![10, 20, 30];
let n = numbers.len;
println!("{n}");
}
$ rustc --edition 2021 vec_len.rs -o vec_len.bin
error[E0616]: field `len` of struct `Vec` is private
--> vec_len.rs:3:21
|
3 | let n = numbers.len;
| ^^^ private field
|
help: a method `len` also exists, call it with parentheses
|
3 | let n = numbers.len();
| ++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0616`.
The code is E0616, not E0615: field len of struct Vec is private. The Vec type's fields are private, so the field the access found cannot be read from outside the type. The help line converges on the same repair from the other direction — a method len also exists, call it with parentheses — and numbers.len() compiles and returns the number of elements. Which of the two codes appears depends on whether the type happens to have a private field with the method's name; the line to write is the same either way.
The exact rule: dot access reads a field, parentheses make the call
The official page for E0615 describes the code in one sentence: attempted to access a method like a field. Its erroneous example is a method on a user-defined struct used as f.method;, its stated repair is to add () after the method if you want to use it, and its alternative reading is the field one: if you wanted to access a field of the struct, check that the field name is spelled correctly. Every family in this guide is that one sentence at a different call site.
The Reference supplies the two expression forms the sentence rests on. A field access expression is a container operand, a dot, and an identifier, and it evaluates to the location of a field; field expressions cannot be followed by a parenthesized list of expressions, because that form is parsed instead as a method call. A method call expression is a receiver, a dot, a path segment, and a parenthesized expression-list; method lookup searches the receiver type's inherent methods first and then the methods provided by visible traits. Drop the parenthesized list and the expression is no longer a method call — it is the field form applied to a name that is not a field, which is exactly what E0615 reports.
The standard library pages pin down the individual methods. String is documented with private fields and implements Deref to str, inheriting str's methods; str::len returns the length of the string in bytes. Vec is likewise documented with private fields, which is why its len access reports the private field (E0616) instead of the method. And to_string is the required method of the ToString trait, automatically implemented for any type that implements Display — a trait method, reached by the same method-call form and bound by the same rule.
The fixes, ranked
- First, and for almost every occurrence: add the parentheses the help line shows —
text.len(),counter.total(),numbers.iter(),n.to_string(). The compiler's suggested line is the fix, not a hint toward one. - Second, if the name was meant to be a field rather than a method: correct the name to the field's name, and check its spelling and its visibility. A private field of another type cannot be read by dot access at all; use the method that type provides for it instead, called with parentheses.
- Third, if the intent really was to use the method as a value — to pass it to
map, store it, or hand it to a function that takes a function: do not use a receiver and a dot. Name the method by its full path, as inString::lenorVec::len, which is the form that yields a callable value. - Fourth, do not work around the error by restructuring the code around it — extracting an unrelated field, precomputing a value the method was supposed to compute, or replacing a chain with a loop solely to avoid the call. The method exists and is callable; the defect is one missing pair of parentheses, and the restructured version hides it rather than fixing it.
Which fix for which cause
| Cause | Message | Fix |
|---|---|---|
| Standard library method, no parentheses, in an assignment | E0615, len on String |
text.len() |
| Method on your own struct, no parentheses | E0615, total on Counter |
counter.total() |
| Method with no parentheses in an argument | E0615, len on String |
show(text.len()) |
| Iterator or adapter method, no parentheses | E0615, iter on Vec |
numbers.iter() |
| Trait method, no parentheses | E0615, to_string on an integer |
n.to_string() |
Method wanted as a value for map |
No error as a full path | String::len, Vec::len |
Private field shares the method's name (Vec::len) |
E0616, field len is private |
numbers.len() |
| ## Checklist |
- Read the second line of the error before anything else.
method, not a fieldsettles the diagnosis: the name exists, it is a method, and no field, import, or type is missing. - Apply the help line literally. The compiler prints the corrected line with
++under the exact characters to add; in this error, that suggestion is complete. - Check the position, not just the line. An E0615 inside an argument list or in the middle of a chain is the same missing call, not a type mismatch or a broken chain — fix the access where it sits.
- Decide which of the two intents the code actually has. Calling the method on this receiver takes parentheses after a dot; using the method as a value takes the full path with no receiver. Mixing the two forms is the error.
- If a field was meant, verify the field's name and visibility before changing anything else. A name that belongs to a method will never become a field access by editing the surrounding code.
- Watch for the neighboring code. The identical slip on
Vec::lenreports E0616 (a private field of the same name) rather than E0615; both help lines end at the same called method. - After the fix, confirm the value is the one the method computes: the fixed programs here print the length, the total, the argument, the iterator count, and the converted string that the uncalled methods were blocking.
Related guides on this site
- E0185 Method Has Self but Trait Does Not Fix
- E0186 Method Lacks Self but Trait Has It Fix
- E0161 Cannot Move Unsized Value Fix
- E0069 Return Without Value Fix
Sources
- Rust Compiler Error Index, E0615 — for E0615 being an attempt to access a method like a field, for the erroneous
f.method;example on a user-defined struct, for adding()after a method to use it, and for checking the spelling when a field was wanted instead. - The Rust Reference, Method call expressions — for a method call consisting of a receiver, a dot, a path segment, and a parenthesized expression-list, and for method lookup searching inherent methods first and then methods provided by visible traits.
- The Rust Reference, Field access expressions — for a field expression being a container operand, a dot, and an identifier that evaluates to the location of a field, and for a field expression followed by a parenthesized list being parsed as a method call instead.
- The Rust Reference, Function pointer types — for function pointer types being written with the
fnkeyword and for function pointers being created by coercion from function items. - std, String — for
Stringhaving private fields, for it implementingDereftostrand inheriting all ofstr's methods, and for its representation as a pointer, a length, and a capacity. - std, str — for
lenreturning the length of the string in bytes, not characters or graphemes. - std, Vec — for
Vecbeing documented with private fields and for its examples obtaining the number of elements by callingvec.len(). - std, ToString — for
to_stringbeing the trait's required method returning aString, and for the trait being automatically implemented for any type that implementsDisplay.
Keep Exploring
The full Rust hub \u2014 ownership, structs and enums, async, and measured comparisons.
Every guide on the site in one list, grouped by topic.
Every browser-only checker and verifier on the site.
The C++, Python, Sysadmin, Rust, Go, and TypeScript hubs.